Program: 73502
Project: 73502
Buggy source:
/** 
 * Override the _transferOutputs() function. First, for tokens that are stored in the actuator event queue and send them to the outside of the platform if physical time has arrived. The second step is to check if this port is a networkedOutput port, if it is, transfer data tokens immediately to the outside by calling super._transferOutputs(port). Finally, we check for current model time, if the current model time is equal to the physical time, we can send the tokens to the outside. Else if current model time has exceeded the physical time, and we still have tokens to transfer, then we have missed the deadline. Else if current model time has not arrived at the physical time, then we put the token along with the port and channel into the actuator event queue, and call fireAt of the executive director so we could send it at a later physical time.
 * @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 the token cannot be sent to the inside.     
 */
protected boolean _transferOutputs(IOPort port) throws IllegalActionException {
  if (!port.isOutput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (port instanceof RefinementPort) {
    return super._transferOutputs(port);
  }
  boolean result=false;
  Tag physicalTag=getPhysicalTag();
  int compare=0;
  while (true) {
    if (_realTimeOutputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent tokenEvent=(RealTimeEvent)_realTimeOutputEventQueue.peek();
    compare=tokenEvent.deliveryTag.compareTo(physicalTag);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      if (isNetworkPort(tokenEvent.port)) {
        throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
      }
      _realTimeOutputEventQueue.poll();
      tokenEvent.port.send(tokenEvent.channel,tokenEvent.token);
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + tokenEvent.token + "String_Node_Str"+ tokenEvent.port.getName());
      }
      result=true;
    }
 else     if (compare < 0) {
      throw new IllegalActionException(tokenEvent.port,"String_Node_Str" + tokenEvent.deliveryTag.timestamp + "String_Node_Str"+ tokenEvent.deliveryTag.microstep+ "String_Node_Str"+ physicalTag.timestamp);
    }
  }
  if (isNetworkPort(port) || _transferImmediately(port)) {
    while (true) {
      if (!super._transferOutputs(port)) {
        break;
      }
 else {
        result=true;
      }
    }
  }
  compare=_currentTime.compareTo(physicalTag.timestamp);
  if (compare == 0) {
    result=result || super._transferOutputs(port);
  }
 else   if (compare < 0) {
    for (int i=0; i < port.getWidthInside(); i++) {
      if (port.hasTokenInside(i)) {
        throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str" + _currentTime + "String_Node_Str"+ physicalTag.timestamp);
      }
    }
  }
 else {
    for (int i=0; i < port.getWidthInside(); i++) {
      try {
        if (port.hasTokenInside(i)) {
          Token t=port.getInside(i);
          RealTimeEvent tokenEvent=new RealTimeEvent(port,i,t,new Tag(_currentTime,_microstep));
          _realTimeOutputEventQueue.add(tokenEvent);
          Actor container=(Actor)getContainer();
          container.getExecutiveDirector().fireAt((Actor)container,_currentTime);
        }
      }
 catch (      NoTokenException ex) {
        throw new InternalErrorException(this,ex,null);
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Override the _transferOutputs() function. First, for tokens that are stored in the actuator event queue and send them to the outside of the platform if physical time has arrived. Second, compare current model time with simulated physical time. if physical time is smaller than current model time, then deadline has been missed. Throw an exception unless the port is annotated with ignoreDeadline. If deadline has been missed and ignoreDeadline is true, or if the current model time is equal to the physical time,  or if the port is annotated with transferImmediate, we send the tokens to the outside. If current model time has not arrived at the physical time, we put the token along with the destination  port and channel into the actuator event queue, and call fireAt of the executive director so we could send it at a later physical time.
 * @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 the token cannot be sent to the inside.     
 */
protected boolean _transferOutputs(IOPort port) throws IllegalActionException {
  if (!port.isOutput() || !port.isOpaque()) {
    throw new IllegalActionException(this,port,"String_Node_Str" + "String_Node_Str");
  }
  if (port instanceof RefinementPort) {
    return super._transferOutputs(port);
  }
  boolean result=false;
  Tag physicalTag=getPhysicalTag();
  int compare=0;
  while (true) {
    if (_realTimeOutputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent tokenEvent=(RealTimeEvent)_realTimeOutputEventQueue.peek();
    compare=tokenEvent.deliveryTag.compareTo(physicalTag);
    if (compare > 0) {
      break;
    }
 else     if (compare == 0) {
      _realTimeOutputEventQueue.poll();
      tokenEvent.port.send(tokenEvent.channel,tokenEvent.token);
      if (_debugging) {
        _debug(getName(),"String_Node_Str" + tokenEvent.token + "String_Node_Str"+ tokenEvent.port.getName());
      }
      result=true;
    }
 else     if (compare < 0) {
      throw new IllegalActionException(tokenEvent.port,"String_Node_Str" + tokenEvent.deliveryTag.timestamp + "String_Node_Str"+ tokenEvent.deliveryTag.microstep+ "String_Node_Str"+ physicalTag.timestamp);
    }
  }
  compare=_currentTime.compareTo(physicalTag.timestamp);
  if (compare < 0 && !_ignoreDeadline(port)) {
    for (int i=0; i < port.getWidthInside(); i++) {
      if (port.hasTokenInside(i)) {
        throw new IllegalActionException(port,"String_Node_Str" + "String_Node_Str" + _currentTime + "String_Node_Str"+ physicalTag.timestamp);
      }
    }
  }
 else   if (compare == 0 || _transferImmediately(port) || (compare < 0 && _ignoreDeadline(port))) {
    while (true) {
      if (!super._transferOutputs(port)) {
        break;
      }
 else {
        result=true;
      }
    }
  }
 else {
    assert(compare > 0);
    for (int i=0; i < port.getWidthInside(); i++) {
      try {
        if (port.hasTokenInside(i)) {
          Token t=port.getInside(i);
          RealTimeEvent tokenEvent=new RealTimeEvent(port,i,t,new Tag(_currentTime,_microstep),null);
          _realTimeOutputEventQueue.add(tokenEvent);
          Actor container=(Actor)getContainer();
          container.getExecutiveDirector().fireAt((Actor)container,_currentTime);
        }
      }
 catch (      NoTokenException ex) {
        throw new InternalErrorException(this,ex,null);
      }
    }
  }
  return result;
}