Пример #1
0
        }     // end of StopSimulation

        #endregion

        #region PlaySimulationTick

        public void PlaySimulationTick(object sender, EventArgs e)
        {
            // security call in case the timer ticks bfore
            // it disabled by stop simulation
            if (!VisualizationEnabled)
            {
                return;
            }

            DateTime timeOfCall;

            if (TickCallIsSimulationCall)
            {
                timeOfCall = CurrentTime;

                DateTime newTime;
                bool     modelRunning = SimulationEngine.RunSingleStepSimulationModel(CurrentTime, out newTime);

                // in case end of model is reached the simulation is stopped
                if (!modelRunning)
                {
                    StopSimulation(false);
                    return;
                } // end if

                SimulationDisplayClock.SetDateTime(CurrentTime);
                SimulationModel.SimulationDrawingEngine.CreateModelVisualization(CurrentTime, SimulationModel, SimulationEngine.CurrentlyTriggeredEvents);
                ProgressBarSimulationProgress.Value = SimulationModel.GetSimulationProgress(CurrentTime);

                _nextSimulationTime = newTime;
                _currentTime        = newTime;
            }
            else
            {
                timeOfCall = NextTimerTime;

                SimulationDisplayClock.SetDateTime(NextTimerTime);
                SimulationModel.SimulationDrawingEngine.CreateModelVisualization(NextTimerTime, SimulationModel, new List <Event>());
                ProgressBarSimulationProgress.Value = SimulationModel.GetSimulationProgress(CurrentTime);
                _nextTimerTime += ConstantTimerStep;
            } // end if

            SimulationTimer.Interval = TimeSpan.FromMilliseconds(Math.Max((int)(((NextTime - timeOfCall).Ticks / ConstantTimerStep.Ticks) * SimulationSpeed), 1));
        } // end of PlaySimulationTick