Пример #1
0
 public void ScheduleDelayedEvent(TimedSignalEventItem item)
 {
     if (item.TimeSpan < TimeSpan.Zero)
     {
         return;
     }
     if (item.TimeSpan == TimeSpan.Zero)
     {
         ScheduleDeltaEvent(item.Item);
     }
     else
     {
         item.Item.Signal.EventQueue.InsertDelayedEvent(item);
         _timeQueue.InsertTime(item.TimeSpan);
     }
 }
        private void scheduler_SimulationTimeProgress(object sender, SimulationTimeProgressEventArgs e)
        {
            TimeSpan timespan = e.TimeSpan;

            while (_timeline.First != null && timespan >= TimeSpan.Zero)
            {
                TimedSignalEventItem item = _timeline.First.Value;
                item.TimeSpan -= timespan;
                timespan       = -item.TimeSpan;
                if (item.TimeSpan <= TimeSpan.Zero)
                {
                    _scheduler.ScheduleDeltaEvent(item.Item);
                    _timeline.RemoveFirst();
                }
            }
        }
        public void InsertDelayedEvent(TimedSignalEventItem item)
        {
            if(_timeline.Count == 0)
            {
                _timeline.AddFirst(item);
                return;
            }

            TimeSpan delay = item.TimeSpan;
            TimeSpan d = TimeSpan.Zero;
            LinkedListNode<TimedSignalEventItem> node = _timeline.First;

            while(true)
            {
                if(d + node.Value.TimeSpan == delay) //already there...
                {
                    item.TimeSpan = node.Value.TimeSpan;
                    RemoveAllAfterIncluding(node);
                    _timeline.AddLast(item);
                    return;
                }

                if(d + node.Value.TimeSpan > delay) //later events available
                {
                    item.TimeSpan = delay - d;
                    RemoveAllAfterIncluding(node);
                    _timeline.AddLast(item);
                    return;
                }

                if(node.Next == null) //last
                {
                    item.TimeSpan = delay - d - node.Value.TimeSpan;
                    _timeline.AddLast(item);
                    return;
                }

                d += node.Value.TimeSpan;
                node = node.Next;
            }
        }
        public void InsertDelayedEvent(TimedSignalEventItem item)
        {
            if (_timeline.Count == 0)
            {
                _timeline.AddFirst(item);
                return;
            }

            TimeSpan delay = item.TimeSpan;
            TimeSpan d     = TimeSpan.Zero;
            LinkedListNode <TimedSignalEventItem> node = _timeline.First;

            while (true)
            {
                if (d + node.Value.TimeSpan == delay) //already there...
                {
                    item.TimeSpan = node.Value.TimeSpan;
                    RemoveAllAfterIncluding(node);
                    _timeline.AddLast(item);
                    return;
                }

                if (d + node.Value.TimeSpan > delay) //later events available
                {
                    item.TimeSpan = delay - d;
                    RemoveAllAfterIncluding(node);
                    _timeline.AddLast(item);
                    return;
                }

                if (node.Next == null) //last
                {
                    item.TimeSpan = delay - d - node.Value.TimeSpan;
                    _timeline.AddLast(item);
                    return;
                }

                d   += node.Value.TimeSpan;
                node = node.Next;
            }
        }
Пример #5
0
 public void ScheduleDelayedEvent(TimedSignalEventItem item)
 {
     if(item.TimeSpan < TimeSpan.Zero)
         return;
     if(item.TimeSpan == TimeSpan.Zero)
         ScheduleDeltaEvent(item.Item);
     else
     {
         item.Item.Signal.EventQueue.InsertDelayedEvent(item);
         _timeQueue.InsertTime(item.TimeSpan);
     }
 }