Exemplo n.º 1
0
 public bool Step()
 {
     if (Model.IsPaused && _queue.IsWorking)
     {
         _queue.Step();
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
 public bool Step()
 {
     if (DijkstraNode.VisualisedNode != null && DijkstraNode.VisualisedNode.IsRunning)
     {
         Util.Wake(DijkstraNode.VisualisedNode);
         return(true);
     }
     else if (Model.IsPaused && _eventQ.IsWorking)
     {
         _eventQ.Step();
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Find the shortest path to every other node. TTL is specified so that if the request was started by receiving a packet it won't be propogated forever.
        /// </summary>
        /// <param name="TTL"></param>
        private void findShortestPaths(int TTL, string msg, bool visualise)
        {
            _queue.QWork(Name + " recalculating shortest paths.", () => {
                Logger.Debug(Name + " " + msg + ". Processing.");
                List <string> changes = new List <string>();
                foreach (IMNodeInternal n in KnownNodes)
                {
                    if (!n.ID.Equals(ID))
                    {
                        findShortestPath(n, changes);
                    }
                }

                bool step = false;
                if (Model.IsPaused && IsCurrentAlgorithm)
                {
                    if (changes.Count > 0)
                    {
                        Say("DV processing routes after " + msg + ". " + changes.Count + " changes necessary.");
                        foreach (var change in changes)
                        {
                            Say(change);
                        }
                    }
                    else
                    {
                        step = true;
                    }
                }

                if (ShouldPrint(visualise))
                {
                    PrintDistanceVector(msg);
                }
                Logger.Info(Name + " processed " + msg + " " + changes.Count + " changes made to the forwarding table.");
                if (changes.Count > 0 && TTL > 0)
                {
                    QueueBroadcastUpdate(TTL, msg, visualise);
                }

                if (step)
                {
                    new Thread(() => _queue.Step()).Start();
                }
            });
        }