Program: 72566
Project: 72566
Buggy source:
/** 
 * Perform co-simulation using the named Functional Mock-up Unit (FMU) file.
 * @param fmuFileName The pathname of the co-simulation .fmu file
 * @param endTime The ending time in seconds.
 * @param stepSize The step size in seconds.
 * @param enableLogging True if logging is enabled.
 * @param csvSeparator The character used for separating fields.Note that sometimes the decimal point in floats is converted to ','.
 * @param outputFileName The output file.
 * @exception Exception If there is a problem parsing the .fmu file or invokingthe methods in the shared library.
 */
@Override public void simulate(String fmuFileName,double endTime,double stepSize,boolean enableLogging,char csvSeparator,String outputFileName) throws Exception {
  _setEnableLogging(enableLogging);
  FMIModelDescription fmiModelDescription=FMUFile.parseFMUFile(fmuFileName);
  _nativeLibrary=fmiModelDescription.getNativeLibrary();
  _modelIdentifier=fmiModelDescription.modelIdentifier;
  String fmuLocation=new File(fmuFileName).toURI().toURL().toString();
  String mimeType="String_Node_Str";
  double timeout=1000;
  byte visible=0;
  int toBeVisibleFMI2=0;
  byte interactive=0;
  byte loggingOn=enableLogging ? (byte)1 : (byte)0;
  int loggingOnFMI2=_enableLogging ? 1 : 0;
  _fmiVersion=Double.valueOf(fmiModelDescription.fmiVersion);
  Pointer fmiComponent=null;
  if (_fmiVersion < 1.5) {
    FMICallbackFunctions.ByValue callbacks=new FMICallbackFunctions.ByValue(new FMULibrary.FMULogger(fmiModelDescription),fmiModelDescription.getFMUAllocateMemory(),new FMULibrary.FMUFreeMemory(),new FMULibrary.FMUStepFinished());
    Function instantiateSlave=fmiModelDescription.getFmiFunction("String_Node_Str");
    fmiComponent=(Pointer)instantiateSlave.invoke(Pointer.class,new Object[]{_modelIdentifier,fmiModelDescription.guid,fmuLocation,mimeType,timeout,visible,interactive,callbacks,loggingOn});
  }
 else {
    FMI20CallbackFunctions callbacks20=new FMI20CallbackFunctions(new FMULibrary.FMULogger(fmiModelDescription),fmiModelDescription.getFMUAllocateMemory(),new FMULibrary.FMUFreeMemory(),new FMULibrary.FMUStepFinished(),fmiComponent);
    Function fmiInstantiateFunction=fmiModelDescription.getFmiFunction("String_Node_Str");
    int fmiType=1;
    if (fmiModelDescription.modelExchange) {
      fmiType=0;
    }
    fmiComponent=(Pointer)fmiInstantiateFunction.invoke(Pointer.class,new Object[]{_modelIdentifier,fmiType,fmiModelDescription.guid,fmiModelDescription.fmuResourceLocation,callbacks20,toBeVisibleFMI2,loggingOnFMI2});
  }
  if (fmiComponent.equals(Pointer.NULL)) {
    throw new RuntimeException("String_Node_Str");
  }
  if (enableLogging) {
    System.out.println("String_Node_Str");
  }
  double startTime=0;
  if (enableLogging) {
    System.out.println("String_Node_Str");
  }
  if (_fmiVersion < 1.5) {
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent,startTime,(byte)1,endTime},"String_Node_Str");
  }
 else {
    double relativeTolerance=1e-4;
    byte _toleranceControlled=(byte)0;
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent,_toleranceControlled,relativeTolerance,startTime,(byte)1,endTime},"String_Node_Str");
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
  }
  File outputFile=new File(outputFileName);
  PrintStream file=null;
  try {
    file=new PrintStream(outputFileName);
    if (enableLogging) {
      System.out.println("String_Node_Str");
    }
    OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,startTime,file,csvSeparator,Boolean.TRUE);
    OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,startTime,file,csvSeparator,Boolean.FALSE);
    double time=startTime;
    Function doStep=fmiModelDescription.getFmiFunction("String_Node_Str");
    while (time < endTime) {
      if (enableLogging) {
        System.out.println("String_Node_Str" + _modelIdentifier + "String_Node_Str"+ time+ "String_Node_Str"+ stepSize+ "String_Node_Str");
      }
      invoke(doStep,new Object[]{fmiComponent,time,stepSize,(byte)1},"String_Node_Str" + time + "String_Node_Str");
      time+=stepSize;
      OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,time,file,csvSeparator,Boolean.FALSE);
    }
    if (_fmiVersion < 2.0) {
      invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
      Function freeSlaveInstance=fmiModelDescription.getFmiFunction("String_Node_Str");
      freeSlaveInstance.invoke(new Object[]{fmiComponent});
    }
 else {
      invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
      Function function=fmiModelDescription.getFmiFunction("String_Node_Str");
      function.invoke(new Object[]{fmiComponent});
    }
  }
  finally {
    if (file != null) {
      file.close();
    }
    if (fmiModelDescription != null) {
      fmiModelDescription.dispose();
    }
  }
  if (enableLogging) {
    System.out.println("String_Node_Str" + outputFile.getCanonicalPath());
    System.out.flush();
  }
}

Fixed version (ground truth):
/** 
 * Perform co-simulation using the named Functional Mock-up Unit (FMU) file.
 * @param fmuFileName The pathname of the co-simulation .fmu file
 * @param endTime The ending time in seconds.
 * @param stepSize The step size in seconds.
 * @param enableLogging True if logging is enabled.
 * @param csvSeparator The character used for separating fields.Note that sometimes the decimal point in floats is converted to ','.
 * @param outputFileName The output file.
 * @exception Exception If there is a problem parsing the .fmu file or invokingthe methods in the shared library.
 */
@Override public void simulate(String fmuFileName,double endTime,double stepSize,boolean enableLogging,char csvSeparator,String outputFileName) throws Exception {
  _setEnableLogging(enableLogging);
  FMIModelDescription fmiModelDescription=FMUFile.parseFMUFile(fmuFileName);
  _nativeLibrary=fmiModelDescription.getNativeLibrary();
  _modelIdentifier=fmiModelDescription.modelIdentifier;
  String fmuLocation=new File(fmuFileName).toURI().toURL().toString();
  String mimeType="String_Node_Str";
  double timeout=1000;
  byte visible=0;
  int toBeVisibleFMI2=0;
  byte interactive=0;
  byte loggingOn=enableLogging ? (byte)1 : (byte)0;
  int loggingOnFMI2=_enableLogging ? 1 : 0;
  _fmiVersion=Double.valueOf(fmiModelDescription.fmiVersion);
  Pointer fmiComponent=null;
  if (_fmiVersion < 1.5) {
    FMICallbackFunctions.ByValue callbacks=new FMICallbackFunctions.ByValue(new FMULibrary.FMULogger(fmiModelDescription),fmiModelDescription.getFMUAllocateMemory(),new FMULibrary.FMUFreeMemory(),new FMULibrary.FMUStepFinished());
    Function instantiateSlave=fmiModelDescription.getFmiFunction("String_Node_Str");
    fmiComponent=(Pointer)instantiateSlave.invoke(Pointer.class,new Object[]{_modelIdentifier,fmiModelDescription.guid,fmuLocation,mimeType,timeout,visible,interactive,callbacks,loggingOn});
  }
 else {
    FMI20CallbackFunctions callbacks20=new FMI20CallbackFunctions(new FMULibrary.FMULogger(fmiModelDescription),fmiModelDescription.getFMUAllocateMemory(),new FMULibrary.FMUFreeMemory(),new FMULibrary.FMUStepFinished(),fmiComponent);
    Function fmiInstantiateFunction=fmiModelDescription.getFmiFunction("String_Node_Str");
    int fmiType=1;
    if (fmiModelDescription.modelExchange) {
      fmiType=0;
    }
    fmiComponent=(Pointer)fmiInstantiateFunction.invoke(Pointer.class,new Object[]{_modelIdentifier,fmiType,fmiModelDescription.guid,fmiModelDescription.fmuResourceLocation,callbacks20,toBeVisibleFMI2,loggingOnFMI2});
  }
  if (fmiComponent.equals(Pointer.NULL)) {
    throw new RuntimeException("String_Node_Str");
  }
  if (enableLogging) {
    System.out.println("String_Node_Str");
  }
  double startTime=0;
  if (enableLogging) {
    System.out.println("String_Node_Str");
  }
  if (_fmiVersion < 1.5) {
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent,startTime,(byte)1,endTime},"String_Node_Str");
  }
 else {
    double relativeTolerance=1e-4;
    byte _toleranceControlled=(byte)0;
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent,_toleranceControlled,relativeTolerance,startTime,(byte)1,endTime},"String_Node_Str");
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
    invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
  }
  File outputFile=new File(outputFileName);
  PrintStream file=null;
  try {
    file=new PrintStream(outputFileName,Charset.defaultCharset().toString());
    if (enableLogging) {
      System.out.println("String_Node_Str");
    }
    OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,startTime,file,csvSeparator,Boolean.TRUE);
    OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,startTime,file,csvSeparator,Boolean.FALSE);
    double time=startTime;
    Function doStep=fmiModelDescription.getFmiFunction("String_Node_Str");
    while (time < endTime) {
      if (enableLogging) {
        System.out.println("String_Node_Str" + _modelIdentifier + "String_Node_Str"+ time+ "String_Node_Str"+ stepSize+ "String_Node_Str");
      }
      invoke(doStep,new Object[]{fmiComponent,time,stepSize,(byte)1},"String_Node_Str" + time + "String_Node_Str");
      time+=stepSize;
      OutputRow.outputRow(_nativeLibrary,fmiModelDescription,fmiComponent,time,file,csvSeparator,Boolean.FALSE);
    }
    if (_fmiVersion < 2.0) {
      invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
      Function freeSlaveInstance=fmiModelDescription.getFmiFunction("String_Node_Str");
      freeSlaveInstance.invoke(new Object[]{fmiComponent});
    }
 else {
      invoke(fmiModelDescription,"String_Node_Str",new Object[]{fmiComponent},"String_Node_Str");
      Function function=fmiModelDescription.getFmiFunction("String_Node_Str");
      function.invoke(new Object[]{fmiComponent});
    }
  }
  finally {
    if (file != null) {
      file.close();
    }
    if (fmiModelDescription != null) {
      fmiModelDescription.dispose();
    }
  }
  if (enableLogging) {
    System.out.println("String_Node_Str" + outputFile.getCanonicalPath());
    System.out.flush();
  }
}