Program: 73527
Project: 73527
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.
 * @param port The port to transfer tokens from.
 * @return True if at least one data token is transferred.
 * @exception IllegalActionException If the port is not an opaqueinput port, if the super class throws it, if physical tag cannot be evaluated, if token cannot be sent to the inside, or if there exists no token in the port, but hasToken() return true.
 */
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;
  Tag physicalTag=getPhysicalTag();
  while (true) {
    if (_realTimeInputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent realTimeEvent=(RealTimeEvent)_realTimeInputEventQueue.peek();
    int compare=realTimeEvent.deliveryTag.compareTo(physicalTag);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      Time lastModelTime=_currentTime;
      int lastMicrostep=_microstep;
      if (isNetworkPort(realTimeEvent.port)) {
        _realTimeInputEventQueue.poll();
        setTag(new Time(this,Double.NEGATIVE_INFINITY),0);
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
 else {
        setTag(realTimeEvent.timestampTag.timestamp,realTimeEvent.timestampTag.microstep);
        _realTimeInputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + realTimeEvent.port.getName());
      }
      _sensorInterruptOccurred=true;
      result=true;
    }
 else {
      throw new IllegalActionException(realTimeEvent.port,"String_Node_Str" + "String_Node_Str" + realTimeEvent.deliveryTag.timestamp + "String_Node_Str"+ realTimeEvent.deliveryTag.microstep+ "String_Node_Str"+ physicalTag.timestamp+ "String_Node_Str"+ physicalTag.microstep);
    }
  }
  Double inputDelay=_getNetworkDriverDelay(port);
  if (inputDelay == null) {
    inputDelay=_getRealTimeDelay(port);
  }
  if (inputDelay == null) {
    inputDelay=0.0;
  }
  if (inputDelay == 0.0) {
    Time lastModelTime=_currentTime;
    int lastMicrostep=_microstep;
    if (isNetworkPort(port)) {
      setTag(new Time(this,Double.NEGATIVE_INFINITY),0);
    }
 else {
      setTag(physicalTag.timestamp,physicalTag.microstep);
    }
    if (super._transferInputs(port)) {
      _sensorInterruptOccurred=true;
      result=true;
    }
    setTag(lastModelTime,lastMicrostep);
  }
 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=physicalTag.timestamp.add(inputDelay);
            RealTimeEvent realTimeEvent=new RealTimeEvent(port,i,t,new Tag(waitUntilTime,physicalTag.microstep),new Tag(physicalTag.timestamp,physicalTag.microstep));
            _realTimeInputEventQueue.add(realTimeEvent);
            result=true;
            Actor container=(Actor)getContainer();
            container.getExecutiveDirector().fireAt((Actor)container,waitUntilTime);
          }
        }
      }
 catch (      NoTokenException ex) {
        throw new IllegalActionException(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.
 * @param port The port to transfer tokens from.
 * @return True if at least one data token is transferred.
 * @exception IllegalActionException If the port is not an opaqueinput port, if the super class throws it, if physical tag cannot be evaluated, if token cannot be sent to the inside, or if there exists no token in the port, but hasToken() return true.
 */
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;
  Tag physicalTag=getPhysicalTag();
  while (true) {
    if (_realTimeInputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent realTimeEvent=(RealTimeEvent)_realTimeInputEventQueue.peek();
    int compare=realTimeEvent.deliveryTag.compareTo(physicalTag);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      Time lastModelTime=_currentTime;
      int lastMicrostep=_microstep;
      if (_isNetworkPort(realTimeEvent.port)) {
        _realTimeInputEventQueue.poll();
        setTag(new Time(this,Double.NEGATIVE_INFINITY),0);
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
 else {
        setTag(realTimeEvent.timestampTag.timestamp,realTimeEvent.timestampTag.microstep);
        _realTimeInputEventQueue.poll();
        realTimeEvent.port.sendInside(realTimeEvent.channel,realTimeEvent.token);
        setTag(lastModelTime,lastMicrostep);
      }
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + realTimeEvent.port.getName());
      }
      _sensorInterruptOccurred=true;
      result=true;
    }
 else {
      throw new IllegalActionException(realTimeEvent.port,"String_Node_Str" + "String_Node_Str" + realTimeEvent.deliveryTag.timestamp + "String_Node_Str"+ realTimeEvent.deliveryTag.microstep+ "String_Node_Str"+ physicalTag.timestamp+ "String_Node_Str"+ physicalTag.microstep);
    }
  }
  Double inputDelay=_getNetworkDriverDelay(port);
  if (inputDelay == null) {
    inputDelay=_getRealTimeDelay(port);
  }
  if (inputDelay == null) {
    inputDelay=0.0;
  }
  if (inputDelay == 0.0) {
    Time lastModelTime=_currentTime;
    int lastMicrostep=_microstep;
    if (_isNetworkPort(port)) {
      setTag(new Time(this,Double.NEGATIVE_INFINITY),0);
    }
 else {
      setTag(physicalTag.timestamp,physicalTag.microstep);
    }
    if (super._transferInputs(port)) {
      _sensorInterruptOccurred=true;
      result=true;
    }
    setTag(lastModelTime,lastMicrostep);
  }
 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=physicalTag.timestamp.add(inputDelay);
            RealTimeEvent realTimeEvent=new RealTimeEvent(port,i,t,new Tag(waitUntilTime,physicalTag.microstep),new Tag(physicalTag.timestamp,physicalTag.microstep));
            _realTimeInputEventQueue.add(realTimeEvent);
            result=true;
            Actor container=(Actor)getContainer();
            container.getExecutiveDirector().fireAt((Actor)container,waitUntilTime);
          }
        }
      }
 catch (      NoTokenException ex) {
        throw new IllegalActionException(this,ex,null);
      }
    }
  }
  return result;
}