Program: 72510
Project: 72510
Buggy source:
/** 
 * Propose a time to advance to. This method is the one implementing the TimeRegulator interface and using the HLA/CERTI Time Management services (if required). Following HLA and CERTI recommendations, if the Time Management is required then we have the following behavior: Case 1: If lookahead = 0 -a) if time-stepped Federate, then the timeAdvanceRequestAvailable() (TARA) service is used; -b) if event-based Federate, then the nextEventRequestAvailable() (NERA) service is used Case 2: If lookahead > 0 -c) if time-stepped Federate, then timeAdvanceRequest() (TAR) is used; -d) if event-based Federate, then the nextEventRequest() (NER) is used; Otherwise the proposedTime is returned. NOTE: For the Ptolemy II - HLA/CERTI cooperation the default (and correct) behavior is the case 1 and CERTI has to be compiled with the option "CERTI_USE_NULL_PRIME_MESSAGE_PROTOCOL".
 * @param proposedTime The proposed time.
 * @return The proposed time or a smaller time.
 * @exception IllegalActionException If this attribute is notcontained by an Actor.
 */
@Override public Time proposeTime(Time proposedTime) throws IllegalActionException {
  Time breakpoint=null;
  if (_rtia == null) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return proposedTime;
  }
  if (_isTimeRegulator && _isTimeConstrained) {
synchronized (this) {
      CertiLogicalTime certiProposedTime=new CertiLogicalTime(proposedTime.getDoubleValue());
      try {
        if (_eventBased) {
          if (_hlaLookAHead > 0) {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequest(certiProposedTime);
          }
 else {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequestAvailable(certiProposedTime);
            _federateAmbassador.timeAdvanceGrant=false;
            while (!(_federateAmbassador.timeAdvanceGrant)) {
              if (_debugging) {
                _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
              }
              try {
                _rtia.tick2();
              }
 catch (              RTIexception e) {
                throw new IllegalActionException(this,e,e.getMessage());
              }
            }
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequest(certiProposedTime);
          }
        }
 else {
          if (_hlaLookAHead > 0) {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequest(certiProposedTime);
          }
 else {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequestAvailable(certiProposedTime);
            _federateAmbassador.timeAdvanceGrant=false;
            while (!(_federateAmbassador.timeAdvanceGrant)) {
              if (_debugging) {
                _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
              }
              try {
                _rtia.tick2();
              }
 catch (              SpecifiedSaveLabelDoesNotExist e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
catch (              ConcurrentAccessAttempted e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
catch (              RTIinternalError e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
            }
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequest(certiProposedTime);
          }
        }
      }
 catch (      InvalidFederationTime e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederationTimeAlreadyPassed e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      TimeAdvanceAlreadyInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeRegulationPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeConstrainedPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederateNotExecutionMember e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      SaveInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RestoreInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RTIinternalError e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      ConcurrentAccessAttempted e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      NoSuchElementException e) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
        }
        return proposedTime;
      }
      _federateAmbassador.timeAdvanceGrant=false;
      while (!(_federateAmbassador.timeAdvanceGrant)) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
        }
        try {
          _rtia.tick2();
        }
 catch (        RTIexception e) {
          throw new IllegalActionException(this,e,e.getMessage());
        }
      }
      try {
        breakpoint=new Time(_director,((CertiLogicalTime)_federateAmbassador.logicalTimeHLA).getTime());
      }
 catch (      IllegalActionException e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
      _putReflectedAttributesOnHlaSubscribers();
    }
  }
  return breakpoint;
}

Fixed version (ground truth):
/** 
 * Propose a time to advance to. This method is the one implementing the TimeRegulator interface and using the HLA/CERTI Time Management services (if required). Following HLA and CERTI recommendations, if the Time Management is required then we have the following behavior: Case 1: If lookahead = 0 -a) if time-stepped Federate, then the timeAdvanceRequestAvailable() (TARA) service is used; -b) if event-based Federate, then the nextEventRequestAvailable() (NERA) service is used Case 2: If lookahead > 0 -c) if time-stepped Federate, then timeAdvanceRequest() (TAR) is used; -d) if event-based Federate, then the nextEventRequest() (NER) is used; Otherwise the proposedTime is returned. NOTE: For the Ptolemy II - HLA/CERTI cooperation the default (and correct) behavior is the case 1 and CERTI has to be compiled with the option "CERTI_USE_NULL_PRIME_MESSAGE_PROTOCOL".
 * @param proposedTime The proposed time.
 * @return The proposed time or a smaller time.
 * @exception IllegalActionException If this attribute is notcontained by an Actor.
 */
@Override public Time proposeTime(Time proposedTime) throws IllegalActionException {
  Time breakpoint=null;
  if (_rtia == null) {
    if (_debugging) {
      _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str");
    }
    return proposedTime;
  }
  if (_lastProposedTime != null) {
    if (_lastProposedTime.compareTo(proposedTime) == 0) {
      try {
        _rtia.tick();
      }
 catch (      ConcurrentAccessAttempted e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RTIinternalError e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
      return _lastProposedTime;
    }
  }
  if (_isTimeRegulator && _isTimeConstrained) {
synchronized (this) {
      CertiLogicalTime certiProposedTime=new CertiLogicalTime(proposedTime.getDoubleValue());
      try {
        if (_eventBased) {
          if (_hlaLookAHead > 0) {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequest(certiProposedTime);
          }
 else {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequestAvailable(certiProposedTime);
            _federateAmbassador.timeAdvanceGrant=false;
            while (!(_federateAmbassador.timeAdvanceGrant)) {
              if (_debugging) {
                _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
              }
              try {
                _rtia.tick2();
              }
 catch (              RTIexception e) {
                throw new IllegalActionException(this,e,e.getMessage());
              }
            }
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.nextEventRequest(certiProposedTime);
          }
        }
 else {
          if (_hlaLookAHead > 0) {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequest(certiProposedTime);
          }
 else {
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequestAvailable(certiProposedTime);
            _federateAmbassador.timeAdvanceGrant=false;
            while (!(_federateAmbassador.timeAdvanceGrant)) {
              if (_debugging) {
                _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
              }
              try {
                _rtia.tick2();
              }
 catch (              SpecifiedSaveLabelDoesNotExist e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
catch (              ConcurrentAccessAttempted e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
catch (              RTIinternalError e) {
                throw new IllegalActionException(this,e,"String_Node_Str");
              }
            }
            if (_debugging) {
              _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
            }
            _rtia.timeAdvanceRequest(certiProposedTime);
          }
        }
      }
 catch (      InvalidFederationTime e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederationTimeAlreadyPassed e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      TimeAdvanceAlreadyInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeRegulationPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      EnableTimeConstrainedPending e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      FederateNotExecutionMember e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      SaveInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RestoreInProgress e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      RTIinternalError e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      ConcurrentAccessAttempted e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
catch (      NoSuchElementException e) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
        }
        return proposedTime;
      }
      _federateAmbassador.timeAdvanceGrant=false;
      while (!(_federateAmbassador.timeAdvanceGrant)) {
        if (_debugging) {
          _debug(this.getDisplayName() + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ certiProposedTime.getTime()+ "String_Node_Str");
        }
        try {
          _rtia.tick2();
        }
 catch (        RTIexception e) {
          throw new IllegalActionException(this,e,e.getMessage());
        }
      }
      try {
        breakpoint=new Time(_director,((CertiLogicalTime)_federateAmbassador.logicalTimeHLA).getTime());
      }
 catch (      IllegalActionException e) {
        throw new IllegalActionException(this,e,"String_Node_Str");
      }
      _putReflectedAttributesOnHlaSubscribers();
    }
  }
  _lastProposedTime=breakpoint;
  return breakpoint;
}