Program: 72481
Project: 72481
Buggy source:
/** 
 * Send output and state model to the port.
 * @param val The values to be sent.
 * @param prt The port where values will be sent.
 * @param index The index of an output or continuous state.
 * @param isState The flag to indicate if continuous state.
 */
private void _sendModelToPort(final double[] val,final TypedIOPort prt,Time time,int index,boolean isState) throws NoRoomException, IllegalActionException {
  double outputQuantum=_internalRelativeQuantum / _quantumScaleFactor;
  if (isState) {
    double lastqSta=_fmiModelDescription.continuousStates.get(index).lastDoubleOutput;
    final int modVarIdx=_modelVariableIndexesOfInputsAndContinuousStates.get(_fmiModelDescription.continuousStates.get(index).name);
    double epsilon=0;
    if (_firstRound) {
      _sendModelToConnectedPort(val,prt,time);
      prt.send(0,new SmoothToken(val,time));
      _fmiModelDescription.continuousStates.get(index).lastDoubleOutput=val[0];
      epsilon=_qssSolver.findQuantum(index) / _quantumScaleFactor;
      _updateModelVariableAttribute(modVarIdx,true);
    }
 else {
      if (Math.abs(val[0] - lastqSta) <= Math.abs(epsilon)) {
        _updateModelVariableAttribute(modVarIdx,false);
        return;
      }
 else {
        _sendModelToConnectedPort(val,prt,time);
        _updateModelVariableAttribute(modVarIdx,true);
        _fmiModelDescription.continuousStates.get(index).lastDoubleOutput=val[0];
        epsilon=_qssSolver.findQuantum(index) / _quantumScaleFactor;
      }
    }
  }
 else {
    double epsilon=0;
    double lastDblOut=_outputs.get(index).lastDoubleOutput;
    if (_firstRound) {
      _sendModelToConnectedPort(val,prt,time);
      _outputs.get(index).lastDoubleOutput=val[0];
      epsilon=Math.abs(outputQuantum * _outputs.get(index).lastDoubleOutput);
    }
 else {
      if (Math.abs(val[0] - lastDblOut) <= Math.abs(epsilon)) {
        return;
      }
 else {
        if (_cancelSendModelToPort(index))         return;
        _sendModelToConnectedPort(val,prt,time);
        _outputs.get(index).lastDoubleOutput=val[0];
        epsilon=Math.abs(outputQuantum * _outputs.get(index).lastDoubleOutput);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Send output and state model to the port.
 * @param val The values to be sent.
 * @param prt The port where values will be sent.
 * @param index The index of an output or continuous state.
 * @param isState The flag to indicate if continuous state.
 */
private void _sendModelToPort(final double[] val,final TypedIOPort prt,Time time,int index,boolean isState) throws NoRoomException, IllegalActionException {
  if (isState) {
    double lastqSta=_fmiModelDescription.continuousStates.get(index).lastDoubleOutput;
    final int modVarIdx=_modelVariableIndexesOfInputsAndContinuousStates.get(_fmiModelDescription.continuousStates.get(index).name);
    double epsilon=0;
    if (_firstRound) {
      _sendModelToConnectedPort(val,prt,time);
      prt.send(0,new SmoothToken(val,time));
      _fmiModelDescription.continuousStates.get(index).lastDoubleOutput=val[0];
      epsilon=_qssSolver.findQuantum(index) / _quantumScaleFactor;
      _updateModelVariableAttribute(modVarIdx,true);
    }
 else {
      if (Math.abs(val[0] - lastqSta) <= Math.abs(epsilon)) {
        _updateModelVariableAttribute(modVarIdx,false);
        return;
      }
 else {
        _sendModelToConnectedPort(val,prt,time);
        _updateModelVariableAttribute(modVarIdx,true);
        _fmiModelDescription.continuousStates.get(index).lastDoubleOutput=val[0];
        epsilon=_qssSolver.findQuantum(index) / _quantumScaleFactor;
      }
    }
  }
 else {
    double epsilon=0;
    double lastDblOut=_outputs.get(index).lastDoubleOutput;
    if (_firstRound) {
      _sendModelToConnectedPort(val,prt,time);
      _outputs.get(index).lastDoubleOutput=val[0];
      epsilon=Math.abs(_outputQuantum * _outputs.get(index).lastDoubleOutput);
    }
 else {
      if (Math.abs(val[0] - lastDblOut) <= Math.abs(epsilon)) {
        return;
      }
 else {
        if (_cancelSendModelToPort(index))         return;
        _sendModelToConnectedPort(val,prt,time);
        _outputs.get(index).lastDoubleOutput=val[0];
        epsilon=Math.abs(_outputQuantum * _outputs.get(index).lastDoubleOutput);
      }
    }
  }
}