Program: 73813
Project: 73813
Buggy source:
/** 
 * Overwrite 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.
 */
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;
  Time physicalTime=getPhysicalTime();
  int compare=0;
  while (true) {
    if (_realTimeOutputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent tokenEvent=(RealTimeEvent)_realTimeOutputEventQueue.peek();
    compare=tokenEvent.deliveryTime.compareTo(physicalTime);
    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.deliveryTime + "String_Node_Str"+ physicalTime);
    }
  }
  if (_isNetworkPort(port) || _transferImmediately(port)) {
    while (true) {
      if (!super._transferOutputs(port)) {
        break;
      }
 else {
        result=true;
      }
    }
  }
  compare=_currentTime.compareTo(physicalTime);
  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"+ physicalTime);
      }
    }
  }
 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,_currentTime);
          _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):
/** 
 * Overwrite 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.
 */
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;
}