Program: 75471
Project: 75471
Buggy source:
/** 
 * Return true if the mode controller wishes to be scheduled for another iteration. Postfire the refinement of the current state of the mode controller. If a type B firing has occurred and exactly one transition is enabled, then change state to the destination state of the enabled transition. Note that a type B firing is the last firing of an actor in an iteration of the HDF graph in which it is embedded. <p> If a state transition to a refinement with different port rates from the previous refinement occurs, then the port rates of the container of this director are updated to be consistant with the port rates of the new state's refinement. The HDF director will be notified of the change in port rates. If a change in port rates occurs and this FSM is governed by an SDF director, an exception will occur.
 * @return True if the mode controller wishes to be scheduled foranother iteration.
 * @exception IllegalActionException If a refinement throws it,if there is no controller, or if an inconsistancy in port rates is detected between refinement actors.
 */
public boolean postfire() throws IllegalActionException {
  FSMActor ctrl=getController();
  State curState=ctrl.currentState();
  TypedActor[] currentRefinement=curState.getRefinement();
  if (currentRefinement == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (_debug_info) {
  }
  boolean postfireReturn=currentRefinement[0].postfire();
  _firingsSoFar++;
  if (_debug_info) {
    System.out.println(getFullName() + "String_Node_Str" + "String_Node_Str"+ _firingsSoFar+ "String_Node_Str"+ _firingsPerScheduleIteration);
  }
  if (_firingsSoFar == _firingsPerScheduleIteration) {
    _firingsSoFar=0;
    Transition lastChosenTr=_getLastChosenTransition();
    if (lastChosenTr == null) {
      if (_debug_info)       System.out.println(getFullName() + "String_Node_Str" + "String_Node_Str"+ curState.getFullName());
      TypedCompositeActor actor=(TypedCompositeActor)(curState.getRefinement())[0];
      _updateInputTokenConsumptionRates(actor);
      _updateOutputTokenProductionRates(actor);
      CompositeActor hdfActor=_getHighestFSM();
      Director director=hdfActor.getExecutiveDirector();
      if (director instanceof HDFDirector) {
        ((HDFDirector)director).invalidateSchedule();
      }
    }
 else {
      if (_debug_info)       System.out.println(getName() + "String_Node_Str");
      State newState=lastChosenTr.destinationState();
      _setCurrentState(newState);
      if (_debug_info)       System.out.println(getName() + "String_Node_Str" + newState.getFullName());
      curState=newState;
      _setCurrentConnectionMap();
      _currentLocalReceiverMap=(Map)_localReceiverMaps.get(ctrl.currentState());
      TypedCompositeActor actor=(TypedCompositeActor)(curState.getRefinement())[0];
      _updateInputTokenConsumptionRates(actor);
      _updateOutputTokenProductionRates(actor);
      CompositeActor hdfActor=_getHighestFSM();
      Director director=hdfActor.getExecutiveDirector();
      if (director instanceof HDFDirector) {
        ((HDFDirector)director).invalidateSchedule();
      }
      if (_debug_info)       System.out.println(getName() + "String_Node_Str" + "String_Node_Str");
    }
    return super.postfire();
  }
  if (_debug_info)   System.out.println(getName() + "String_Node_Str");
  return postfireReturn;
}

Fixed version (ground truth):
/** 
 * Return true if the mode controller wishes to be scheduled for another iteration. Postfire the refinement of the current state of the mode controller. If a type B firing has occurred and exactly one transition is enabled, then change state to the destination state of the enabled transition. Note that a type B firing is the last firing of an actor in an iteration of the HDF graph in which it is embedded. <p> If a state transition to a refinement with different port rates from the previous refinement occurs, then the port rates of the container of this director are updated to be consistant with the port rates of the new state's refinement. The HDF director will be notified of the change in port rates. If a change in port rates occurs and this FSM is governed by an SDF director, an exception will occur.
 * @return True if the mode controller wishes to be scheduled foranother iteration.
 * @exception IllegalActionException If a refinement throws it,if there is no controller, or if an inconsistancy in port rates is detected between refinement actors.
 */
public boolean postfire() throws IllegalActionException {
  FSMActor ctrl=getController();
  State curState=ctrl.currentState();
  TypedActor[] currentRefinement=curState.getRefinement();
  if (currentRefinement == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  if (_debug_info) {
  }
  boolean postfireReturn=currentRefinement[0].postfire();
  _firingsSoFar++;
  if (_debug_info) {
    System.out.println(getFullName() + "String_Node_Str" + "String_Node_Str"+ _firingsSoFar+ "String_Node_Str"+ _firingsPerScheduleIteration);
  }
  if (_firingsSoFar == _firingsPerScheduleIteration) {
    _firingsSoFar=0;
    Transition lastChosenTr=_getLastChosenTransition();
    if (lastChosenTr == null) {
      if (_debug_info)       System.out.println(getFullName() + "String_Node_Str" + "String_Node_Str"+ curState.getFullName());
      TypedCompositeActor actor=(TypedCompositeActor)(curState.getRefinement())[0];
      Director refinementDir=actor.getDirector();
      _updateInputTokenConsumptionRates(actor);
      _updateOutputTokenProductionRates(actor);
      CompositeActor hdfActor=_getHighestFSM();
      Director director=hdfActor.getExecutiveDirector();
      if (director instanceof HDFDirector) {
        ((HDFDirector)director).invalidateSchedule();
      }
    }
 else {
      if (_debug_info)       System.out.println(getName() + "String_Node_Str");
      State newState=lastChosenTr.destinationState();
      _setCurrentState(newState);
      if (_debug_info)       System.out.println(getName() + "String_Node_Str" + newState.getFullName());
      BooleanToken resetToken=(BooleanToken)lastChosenTr.reset.getToken();
      if (resetToken.booleanValue()) {
        initialize();
      }
      curState=newState;
      _setCurrentConnectionMap();
      _currentLocalReceiverMap=(Map)_localReceiverMaps.get(ctrl.currentState());
      TypedCompositeActor actor=(TypedCompositeActor)(curState.getRefinement())[0];
      Director refinementDir=actor.getDirector();
      if (refinementDir instanceof HDFFSMDirector) {
        refinementDir.postfire();
      }
 else       if (refinementDir instanceof HDFDirector) {
        Scheduler refinmentSched=((StaticSchedulingDirector)refinementDir).getScheduler();
        refinmentSched.setValid(false);
        refinmentSched.getSchedule();
        ((HDFDirector)refinementDir).getSchedule();
      }
 else       if (refinementDir instanceof SDFDirector) {
        Scheduler refinmentSched=((StaticSchedulingDirector)refinementDir).getScheduler();
        refinmentSched.setValid(false);
        refinmentSched.getSchedule();
      }
 else {
      }
      _updateInputTokenConsumptionRates(actor);
      _updateOutputTokenProductionRates(actor);
      CompositeActor hdfActor=_getHighestFSM();
      Director director=hdfActor.getExecutiveDirector();
      if (director instanceof HDFDirector) {
        ((HDFDirector)director).invalidateSchedule();
      }
      if (_debug_info)       System.out.println(getName() + "String_Node_Str" + "String_Node_Str");
    }
    return super.postfire();
  }
  if (_debug_info)   System.out.println(getName() + "String_Node_Str");
  return postfireReturn;
}