Program: 74038
Project: 74038
Buggy source:
/** 
 * For all events in the sensorEventQueue, transfer input events that are ready. For all events that are currently sitting at the input port, if the realTimeDelay is 0.0, then transfer them into the platform, otherwise move them into the sensorEventQueue and call fireAt() of the executive director. In either case, if the input port is a networkPort, we make sure the timestamp of the data token transmitted is set to the timestamp of the local event associated with this token.
 * @exception IllegalActionException If the port is not an opaqueinput port.
 * @param port The port to transfer tokens from.
 * @return True if at least one data token is transferred.
 */
protected boolean _transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  boolean result=false;
  Time physicalTime=_getPhysicalTime();
  while (true) {
    if (_realTimeOutputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent realTimeEvent=(RealTimeEvent)_realTimeOutputEventQueue.peek();
    int compare=realTimeEvent.deliveryTime.compareTo(physicalTime);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      Parameter parameter=(Parameter)((NamedObj)realTimeEvent.port).getAttribute("String_Node_Str");
      double realTimeDelay=0.0;
      if (parameter != null) {
        realTimeDelay=((DoubleToken)parameter.getToken()).doubleValue();
      }
 else {
        throw new IllegalActionException("String_Node_Str");
      }
      Time lastModelTime=_currentTime;
      if (_isNetworkPort(realTimeEvent.port)) {
        _realTimeOutputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
      }
 else {
        int lastMicrostep=_microstep;
        setTag(realTimeEvent.deliveryTime.subtract(realTimeDelay),0);
        _realTimeOutputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + realTimeEvent.port.getName());
      }
      result=true;
    }
 else {
      throw new IllegalActionException(realTimeEvent.port,"String_Node_Str" + "String_Node_Str" + realTimeEvent.deliveryTime + "String_Node_Str"+ physicalTime);
    }
  }
  Parameter parameter=(Parameter)((NamedObj)port).getAttribute("String_Node_Str");
  double realTimeDelay=0.0;
  if (parameter != null) {
    realTimeDelay=((DoubleToken)parameter.getToken()).doubleValue();
  }
  if (realTimeDelay == 0.0) {
    Time lastModelTime=_currentTime;
    if (_isNetworkPort(port)) {
      super._transferInputs(port);
    }
 else {
      setTag(physicalTime,0);
      result=result || super._transferInputs(port);
      setTag(lastModelTime,0);
    }
  }
 else {
    for (int i=0; i < port.getWidth(); i++) {
      try {
        if (i < port.getWidthInside()) {
          if (port.hasToken(i)) {
            Token t=port.get(i);
            Time waitUntilTime=physicalTime.add(realTimeDelay);
            RealTimeEvent realTimeEvent=new RealTimeEvent(port,i,t,waitUntilTime);
            _realTimeOutputEventQueue.add(realTimeEvent);
            result=true;
            Actor container=(Actor)getContainer();
            container.getExecutiveDirector().fireAt((Actor)container,waitUntilTime);
          }
        }
      }
 catch (      NoTokenException ex) {
        throw new InternalErrorException(this,ex,null);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * For all events in the sensorEventQueue, transfer input events that are ready. For all events that are currently sitting at the input port, if the realTimeDelay is 0.0, then transfer them into the platform, otherwise move them into the sensorEventQueue and call fireAt() of the executive director. In either case, if the input port is a networkPort, we make sure the timestamp of the data token transmitted is set to the timestamp of the local event associated with this token.
 * @exception IllegalActionException If the port is not an opaqueinput port.
 * @param port The port to transfer tokens from.
 * @return True if at least one data token is transferred.
 */
protected boolean _transferInputs(IOPort port) throws IllegalActionException {
  if (!port.isInput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (port instanceof RefinementPort) {
    return super._transferInputs(port);
  }
  boolean result=false;
  Time physicalTime=_getPhysicalTime();
  while (true) {
    if (_realTimeOutputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent realTimeEvent=(RealTimeEvent)_realTimeOutputEventQueue.peek();
    int compare=realTimeEvent.deliveryTime.compareTo(physicalTime);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      Parameter parameter=(Parameter)((NamedObj)realTimeEvent.port).getAttribute("String_Node_Str");
      double realTimeDelay=0.0;
      if (parameter != null) {
        realTimeDelay=((DoubleToken)parameter.getToken()).doubleValue();
      }
 else {
        throw new IllegalActionException("String_Node_Str");
      }
      Time lastModelTime=_currentTime;
      if (_isNetworkPort(realTimeEvent.port)) {
        _realTimeOutputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
      }
 else {
        int lastMicrostep=_microstep;
        setTag(realTimeEvent.deliveryTime.subtract(realTimeDelay),0);
        _realTimeOutputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + realTimeEvent.port.getName());
      }
      result=true;
    }
 else {
      throw new IllegalActionException(realTimeEvent.port,"String_Node_Str" + "String_Node_Str" + realTimeEvent.deliveryTime + "String_Node_Str"+ physicalTime);
    }
  }
  Parameter parameter=(Parameter)((NamedObj)port).getAttribute("String_Node_Str");
  double realTimeDelay=0.0;
  if (parameter != null) {
    realTimeDelay=((DoubleToken)parameter.getToken()).doubleValue();
  }
  if (realTimeDelay == 0.0) {
    Time lastModelTime=_currentTime;
    if (_isNetworkPort(port)) {
      super._transferInputs(port);
    }
 else {
      setTag(physicalTime,0);
      result=result || super._transferInputs(port);
      setTag(lastModelTime,0);
    }
  }
 else {
    for (int i=0; i < port.getWidth(); i++) {
      try {
        if (i < port.getWidthInside()) {
          if (port.hasToken(i)) {
            Token t=port.get(i);
            Time waitUntilTime=physicalTime.add(realTimeDelay);
            RealTimeEvent realTimeEvent=new RealTimeEvent(port,i,t,waitUntilTime);
            _realTimeOutputEventQueue.add(realTimeEvent);
            result=true;
            Actor container=(Actor)getContainer();
            container.getExecutiveDirector().fireAt((Actor)container,waitUntilTime);
          }
        }
      }
 catch (      NoTokenException ex) {
        throw new InternalErrorException(this,ex,null);
      }
    }
  }
  return result;
}