Пример #1
0
        /// <summary>
        /// This method is called every simulationTimeInterval when the simulation is running.
        /// It must perform all necessary simulation updates.
        /// (A method for the timer event delagate: used for the discrete event simulation updates).
        /// </summary>
        private void UpdatePlanetsAndSimulationTime(Object source, System.Timers.ElapsedEventArgs e)
        {
            // Update the simulation time and the planet status'
            simulationTime += simulationTimeInterval;
            nPlanetsAndSun.UpdateAll();

            // If end of the simulation, reset simulation time to 0 and dispose of the current timer
            if (simulationTime >= simulationTimeInterval * duration)
            {
                timer.Close();
            }
        }
 /// <summary>
 /// This method is called every simulationTimeInterval when the simulation is running.
 /// It must perform all necessary simulation updates.
 /// (A method for the timer event delagate: used for the discrete event simulation updates).
 /// </summary>
 private void UpdatePlanetsAndSimulationTime(Object source, System.Timers.ElapsedEventArgs e)
 {
     if (simulationTime < duration * simulationTimeInterval)
     {
         simulationTime = GetSimulationTime() + duration;
     }
     if (GetSimulationTime() == duration * simulationTimeInterval)
     {
         timer.Stop();
         return;
     }
     nPlanetsAndSun.UpdateAll();
 }
Пример #3
0
 /// <summary>
 /// This method is called every simulationTimeInterval when the simulation is running.
 /// It must perform all necessary simulation updates.
 /// (A method for the timer event delagate: used for the discrete event simulation updates).
 /// </summary>
 private void UpdatePlanetsAndSimulationTime(Object source, System.Timers.ElapsedEventArgs e)
 {
     //Hint: you can implement this method without using "source" or "e" in the method itself.
     if (simulationTime < duration - simulationTimeInterval)
     {
         nPlanetsAndSun.UpdateAll();
         simulationTime += simulationTimeInterval;
     }
     else
     {
         timer.Stop();
     }
 }