Ejemplo n.º 1
0
 /// <summary>
 /// Activates required subphase
 /// </summary>
 /// <param name="resolution">Simulation resolution</param>
 /// <param name="vissim">Vissim instance</param>
 /// <param name="signalControllerId">Id of the signal controller</param>
 /// <returns>True if phase is over, false if not</returns>
 public bool Step(int resolution, int signalControllerId, Vissim vissim)
 {
     if (currentSubPhase.Step(resolution, signalControllerId, vissim))
     {
         currentSubPhaseIndex++;
         if (currentSubPhaseIndex == subPhaseCount)
         {
             currentSubPhaseIndex = 0;
             currentDuration      = 0;
             currentSubPhase      = subPhases[currentSubPhaseIndex];
             return(true);
         }
         currentSubPhase = subPhases[currentSubPhaseIndex];
     }
     currentDuration += 1 / resolution;
     return(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the initial subphase and current time point inside the subphase
        /// </summary>
        private void SetInitialSubPhase()
        {
            float checkedPhasesDuration = 0;

            currentSubPhaseIndex = 0;
            foreach (SubPhase subPhase in subPhases)
            {
                if (checkedPhasesDuration + subPhase.Duration >= currentDuration)
                {
                    this.currentSubPhase     = subPhase;
                    subPhase.CurrentDuration = currentDuration - checkedPhasesDuration;
                    break;
                }
                else
                {
                    checkedPhasesDuration += subPhase.Duration;
                    currentSubPhaseIndex++;
                }
            }
        }