Ejemplo n.º 1
0
        /// <summary>
        /// process to next subpulse
        /// </summary>
        /// <param name="currentDateTime"></param>
        /// <param name="maxSpan">maximum time delta</param>
        /// <returns>datetime processed to</returns>
        private void ProcessToNextInterupt(DateTime nextInteruptDateTime)
        {
            TimeSpan span         = (nextInteruptDateTime - _systemLocalDateTime);
            int      deltaSeconds = (int)span.TotalSeconds;

            if (QueuedProcesses.ContainsKey(nextInteruptDateTime))
            {
                foreach (var systemProcess in QueuedProcesses[nextInteruptDateTime].SystemProcessors)
                {
                    Stopwatch sw = new Stopwatch();
                    sw.Start();
                    systemProcess.ProcessManager(_entityManager, deltaSeconds);
                    sw.Stop();
                    ProcessTime[systemProcess.GetType()] = sw.Elapsed;
                    AddSystemInterupt(nextInteruptDateTime + systemProcess.RunFrequency, systemProcess); //sets the next interupt for this hotloop process
                }
                foreach (var instanceProcessSet in QueuedProcesses[nextInteruptDateTime].InstanceProcessors)
                {
                    var       processor = _processManager.GetInstanceProcessor(instanceProcessSet.Key);
                    Stopwatch sw        = new Stopwatch();
                    sw.Start();
                    foreach (var entity in instanceProcessSet.Value)
                    {
                        processor.ProcessEntity(entity, nextInteruptDateTime);
                    }
                    sw.Stop();
                    ProcessTime[processor.GetType()] = sw.Elapsed;
                }
                QueuedProcesses.Remove(nextInteruptDateTime); //once all the processes have been run for that datetime, remove it from the dictionary.
            }
            StarSysDateTime = nextInteruptDateTime;           //update the localDateTime and invoke the SystemDateChangedEvent
        }