Program: 72977
Project: 72977
Buggy source:
/** 
 * Before super.fire() is called, transfer all input events that are ready are transferred. After super.fire() is called, transfer all output events that are ready are transferred.
 */
public void fire() throws IllegalActionException {
  List<PtidesEvent> list=_inputEventQueue.get(getModelTime());
  if (list != null) {
    for (    PtidesEvent event : list) {
      if (event.ioPort() != null) {
        _currentLogicalTime=event.timeStamp();
        _currentSourceTimestamp=event.sourceTimestamp();
        _currentLogicalIndex=event.microstep();
        event.receiver().put(event.token());
        _currentLogicalTime=null;
      }
    }
    _inputEventQueue.remove(getModelTime());
  }
  super.fire();
  list=_outputEventQueue.get(getModelTime());
  if (list != null) {
    for (    PtidesEvent event : list) {
      _currentLogicalTime=event.timeStamp();
      _currentSourceTimestamp=event.sourceTimestamp();
      _currentLogicalIndex=event.microstep();
      if (event.ioPort() instanceof MetroIIPtidesPort) {
        double deviceDelay=_getDoubleParameterValue(event.ioPort(),"String_Node_Str");
        Queue<PtidesEvent> ptidesOutputPortList=_ptidesOutputPortEventQueue.get(event.ioPort());
        if (ptidesOutputPortList == null) {
          ptidesOutputPortList=new LinkedList<PtidesEvent>();
        }
        PtidesEvent newEvent=new PtidesEvent(event.ioPort(),event.channel(),event.timeStamp(),event.microstep(),event.depth(),event.token(),event.receiver(),localClock.getLocalTime().add(deviceDelay),event.sourceTimestamp());
        ptidesOutputPortList.add(newEvent);
        _ptidesOutputPortEventQueue.put((MetroIIPtidesPort)event.ioPort(),ptidesOutputPortList);
      }
      _currentLogicalTime=null;
    }
    _outputEventQueue.remove(getModelTime());
  }
  for (  MetroIIPtidesPort port : _ptidesOutputPortEventQueue.keySet()) {
    Queue<PtidesEvent> ptidesOutputPortList=_ptidesOutputPortEventQueue.get(port);
    if (ptidesOutputPortList != null && ptidesOutputPortList.size() > 0) {
      PtidesEvent event=ptidesOutputPortList.peek();
      if (event.absoluteDeadline().equals(localClock.getLocalTime())) {
        _currentLogicalTime=event.timeStamp();
        _currentSourceTimestamp=event.sourceTimestamp();
        _currentLogicalIndex=event.microstep();
        event.ioPort().send(0,event.token());
        _currentLogicalTime=null;
        ptidesOutputPortList.poll();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Before super.fire() is called, transfer all input events that are ready are transferred. After super.fire() is called, transfer all output events that are ready are transferred.
 */
public void fire() throws IllegalActionException {
  List<PtidesEvent> list=_inputEventQueue.get(getModelTime());
  if (list != null) {
    for (    PtidesEvent event : list) {
      if (event.ioPort() != null) {
        _currentLogicalTime=event.timeStamp();
        _currentSourceTimestamp=event.sourceTimestamp();
        _currentLogicalIndex=event.microstep();
        event.receiver().put(event.token());
        _currentLogicalTime=null;
        if (_debugging) {
          _debug("String_Node_Str" + event.ioPort());
        }
      }
    }
    _inputEventQueue.remove(getModelTime());
  }
  super.fire();
  list=_outputEventQueue.get(getModelTime());
  if (list != null) {
    for (    PtidesEvent event : list) {
      _currentLogicalTime=event.timeStamp();
      _currentSourceTimestamp=event.sourceTimestamp();
      _currentLogicalIndex=event.microstep();
      if (event.ioPort() instanceof MetroIIPtidesPort) {
        double deviceDelay=_getDoubleParameterValue(event.ioPort(),"String_Node_Str");
        Queue<PtidesEvent> ptidesOutputPortList=_ptidesOutputPortEventQueue.get(event.ioPort());
        if (ptidesOutputPortList == null) {
          ptidesOutputPortList=new LinkedList<PtidesEvent>();
        }
        PtidesEvent newEvent=new PtidesEvent(event.ioPort(),event.channel(),event.timeStamp(),event.microstep(),event.depth(),event.token(),event.receiver(),localClock.getLocalTime().add(deviceDelay),event.sourceTimestamp());
        ptidesOutputPortList.add(newEvent);
        _ptidesOutputPortEventQueue.put((MetroIIPtidesPort)event.ioPort(),ptidesOutputPortList);
      }
      _currentLogicalTime=null;
    }
    _outputEventQueue.remove(getModelTime());
  }
  for (  MetroIIPtidesPort port : _ptidesOutputPortEventQueue.keySet()) {
    Queue<PtidesEvent> ptidesOutputPortList=_ptidesOutputPortEventQueue.get(port);
    if (ptidesOutputPortList != null && ptidesOutputPortList.size() > 0) {
      PtidesEvent event=ptidesOutputPortList.peek();
      if (event.absoluteDeadline().equals(localClock.getLocalTime())) {
        _currentLogicalTime=event.timeStamp();
        _currentSourceTimestamp=event.sourceTimestamp();
        _currentLogicalIndex=event.microstep();
        event.ioPort().send(0,event.token());
        _currentLogicalTime=null;
        ptidesOutputPortList.poll();
      }
    }
  }
}