Program: 74039
Project: 74039
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");
  }
  boolean result=false;
  Time physicalTime=_getPhysicalTime();
  int compare=0;
  while (true) {
    if (_realTimeInputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent tokenEvent=(RealTimeEvent)_realTimeInputEventQueue.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");
      }
      _realTimeInputEventQueue.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)) {
    while (true) {
      if (!super._transferOutputs(port)) {
        break;
      }
    }
  }
  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);
          _realTimeInputEventQueue.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;
  Time physicalTime=_getPhysicalTime();
  int compare=0;
  while (true) {
    if (_realTimeInputEventQueue.isEmpty()) {
      break;
    }
    RealTimeEvent tokenEvent=(RealTimeEvent)_realTimeInputEventQueue.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");
      }
      _realTimeInputEventQueue.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)) {
    while (true) {
      if (!super._transferOutputs(port)) {
        break;
      }
    }
  }
  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);
          _realTimeInputEventQueue.add(tokenEvent);
          Actor container=(Actor)getContainer();
          container.getExecutiveDirector().fireAt((Actor)container,_currentTime);
        }
      }
 catch (      NoTokenException ex) {
        throw new InternalErrorException(this,ex,null);
      }
    }
  }
  return result;
}