Program: 72868
Project: 72868
Buggy source:
/** 
 * Put a trigger event into the event queue. <p> The trigger event has the same timestamp as that of the director. The microstep of this event is always equal to the current microstep of this director. The depth for the queued event is the depth of the destination IO port. Finally, the token and the destination receiver are also stored in the event. </p><p> If the event queue is not ready or the actor that contains the destination port is disabled, do nothing.</p>
 * @param ioPort The destination IO port.
 * @param token The token associated with this event.
 * @param receiver The destination receiver.
 * @exception IllegalActionException If the time argument is not thecurrent time, or the depth of the given IO port has not be calculated, or the new event can not be enqueued.
 */
protected void _enqueueTriggerEvent(IOPort ioPort,Token token,Receiver receiver) throws IllegalActionException {
  Actor actor=(Actor)ioPort.getContainer();
  if (_eventQueue == null || _disabledActors != null && _disabledActors.contains(actor)) {
    return;
  }
  int depth=_getDepthOfIOPort(ioPort);
  if (_debugging) {
    _debug("String_Node_Str",((NamedObj)actor).getName(),"String_Node_Str" + ioPort + "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _microstep+ "String_Node_Str"+ depth);
  }
  PtidesEvent newEvent=new PtidesEvent(ioPort,ioPort.getChannelForReceiver(receiver),getModelTime(),_currentLogicalIndex,depth,token,receiver,_currentSourceTimestamp);
  if (ioPort.isOutput()) {
    Time deliveryTime;
    deliveryTime=localClock.getLocalTime();
    if (((PtidesPort)ioPort).isActuatorPort()) {
      if (((PtidesPort)ioPort).actuateAtEventTimestamp()) {
        deliveryTime=getModelTime().subtract(_getDoubleParameterValue(ioPort,"String_Node_Str"));
      }
      if (getModelTime().compareTo(deliveryTime) < 0) {
        newEvent=_handleTimingError((PtidesPort)ioPort,newEvent,"String_Node_Str" + ioPort + "String_Node_Str"+ "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ localClock.getLocalTime());
      }
    }
 else     if (((PtidesPort)ioPort).isNetworkTransmitterPort()) {
      if (localClock.getLocalTime().subtract(getModelTime()).getDoubleValue() > _getDoubleParameterValue(ioPort,"String_Node_Str")) {
        newEvent=_handleTimingError((PtidesPort)ioPort,newEvent,"String_Node_Str" + "String_Node_Str" + localClock.getLocalTime() + "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _getDoubleParameterValue(ioPort,"String_Node_Str"));
      }
    }
    if (newEvent != null) {
      List<PtidesEvent> list=_outputEventDeadlines.get(deliveryTime);
      if (list == null) {
        list=new ArrayList<PtidesEvent>();
      }
      list.add(newEvent);
      _outputEventDeadlines.put(deliveryTime,list);
      if (_debugging) {
        _debug("String_Node_Str" + deliveryTime);
      }
    }
  }
 else {
    _eventQueue.put(newEvent);
    if (_numberOfTokensPerPort == null) {
      _numberOfTokensPerPort=new HashMap<IOPort,Integer>();
    }
    IOPort port=newEvent.ioPort();
    if (port != null) {
      _numberOfTokensPerPort.put(port,_numberOfTokensPerPort.get(port) + 1);
    }
  }
}

Fixed version (ground truth):
/** 
 * Put a trigger event into the event queue. <p> The trigger event has the same timestamp as that of the director. The microstep of this event is always equal to the current microstep of this director. The depth for the queued event is the depth of the destination IO port. Finally, the token and the destination receiver are also stored in the event. </p><p> If the event queue is not ready or the actor that contains the destination port is disabled, do nothing.</p>
 * @param ioPort The destination IO port.
 * @param token The token associated with this event.
 * @param receiver The destination receiver.
 * @exception IllegalActionException If the time argument is not thecurrent time, or the depth of the given IO port has not be calculated, or the new event can not be enqueued.
 */
protected void _enqueueTriggerEvent(IOPort ioPort,Token token,Receiver receiver) throws IllegalActionException {
  Actor actor=(Actor)ioPort.getContainer();
  if (_eventQueue == null || _disabledActors != null && _disabledActors.contains(actor)) {
    return;
  }
  int depth=_getDepthOfIOPort(ioPort);
  if (_debugging) {
    _debug("String_Node_Str",((NamedObj)actor).getName(),"String_Node_Str" + ioPort + "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _microstep+ "String_Node_Str"+ depth);
  }
  PtidesEvent newEvent=new PtidesEvent(ioPort,ioPort.getChannelForReceiver(receiver),getModelTime(),_currentLogicalIndex,depth,token,receiver,_currentSourceTimestamp);
  if (ioPort.isOutput()) {
    Time deliveryTime;
    deliveryTime=localClock.getLocalTime();
    if (((PtidesPort)ioPort).isActuatorPort()) {
      if (((PtidesPort)ioPort).actuateAtEventTimestamp()) {
        deliveryTime=getModelTime().subtract(_getDoubleParameterValue(ioPort,"String_Node_Str"));
      }
      if (getModelTime().compareTo(deliveryTime) < 0) {
        newEvent=_handleTimingError((PtidesPort)ioPort,newEvent,"String_Node_Str" + ioPort + "String_Node_Str"+ "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ localClock.getLocalTime());
      }
    }
 else     if (((PtidesPort)ioPort).isNetworkTransmitterPort()) {
      if (localClock.getLocalTime().subtract(getModelTime()).getDoubleValue() > _getDoubleParameterValue(ioPort,"String_Node_Str")) {
        newEvent=_handleTimingError((PtidesPort)ioPort,newEvent,"String_Node_Str" + "String_Node_Str" + localClock.getLocalTime() + "String_Node_Str"+ getModelTime()+ "String_Node_Str"+ _getDoubleParameterValue(ioPort,"String_Node_Str"));
      }
    }
    if (newEvent != null) {
      List<PtidesEvent> list=_outputEventDeadlines.get(deliveryTime);
      if (list == null) {
        list=new ArrayList<PtidesEvent>();
      }
      list.add(newEvent);
      _outputEventDeadlines.put(deliveryTime,list);
      if (_debugging) {
        _debug("String_Node_Str" + deliveryTime);
      }
    }
  }
 else {
    _eventQueue.put(newEvent);
    if (_numberOfTokensPerPort == null) {
      _numberOfTokensPerPort=new HashMap<IOPort,Integer>();
    }
    IOPort port=newEvent.ioPort();
    if (port != null) {
      if (_numberOfTokensPerPort == null) {
        _numberOfTokensPerPort=new HashMap<IOPort,Integer>();
      }
      Integer numberofTokens=_numberOfTokensPerPort.get(port);
      if (numberofTokens == null) {
        numberofTokens=0;
      }
      _numberOfTokensPerPort.put(port,numberofTokens + 1);
    }
  }
}