コード例 #1
0
ファイル: Agent.cs プロジェクト: howbani/RingRouting
        private void OutOfRangeTimer_Tick(object sender, EventArgs e)
        {
            if (waitingTimesForSink > 7)
            {
                Node.isSinkAgent = false;
                PublicParameters.SinkNode.MainWindow.Dispatcher.Invoke(() => Node.Ellipse_HeaderAgent_Mark.Visibility = Visibility.Hidden);
                Node.NeighborsTable.RemoveAll(sinkItem => sinkItem.NeiNode.ID == PublicParameters.SinkNode.ID);
                SinkOutOfRangeTimer.Stop();
                if (AgentBuffer.Count > 0)
                {
                    do
                    {
                        Packet packet = AgentBuffer.Dequeue();
                        packet.isDelivered = false;
                        Node.updateStates(packet);
                    } while (AgentBuffer.Count > 0);
                }
            }
            else if (AgentBuffer.Count > 0)
            {
                if (isSinkInRange())
                {
                    SinkOutOfRangeTimer.Stop();
                    do
                    {
                        Packet packet = AgentBuffer.Dequeue();
                        packet.Destination = PublicParameters.SinkNode;
                        packet.TimeToLive += PublicParameters.HopsErrorRange;
                        Node.sendDataPack(packet);
                    } while (AgentBuffer.Count > 0);
                }
                else
                {
                    try
                    {
                        if (NewAgent != null)
                        {
                            do
                            {
                                Packet packet = AgentBuffer.Dequeue();
                                packet.Destination = NewAgent;
                                packet.TimeToLive += Node.maxHopsForDestination(NewAgent.CenterLocation);
                                Node.sendDataPack(packet);
                            } while (AgentBuffer.Count > 0);
                        }
                    }
                    catch (NullReferenceException excep)
                    {
                        Console.WriteLine(excep.Message + " new agent is null");
                    }
                }
            }
            else if (isSinkInRange() && AgentBuffer.Count == 0)
            {
                SinkOutOfRangeTimer.Stop();
            }

            waitingTimesForSink++;
        }
コード例 #2
0
ファイル: Agent.cs プロジェクト: howbani/RingRouting
 public void AgentStorePacket(Packet packet)
 {
     initiateSinkOutOfRangeTimer();
     AgentBuffer.Enqueue(packet);
     if (AgentBuffer.Count > 20)
     {
         Console.WriteLine();
     }
 }
コード例 #3
0
ファイル: Agent.cs プロジェクト: howbani/RingRouting
 private void NewAgentTimer_Tick(Object sender, EventArgs e)
 {
     OldAgentTimer.Stop();
     OldAgent      = null;
     NewAgent      = null;
     OldAgentTimer = null;
     if (AgentBuffer.Count > 0)
     {
         foreach (Packet packet in AgentBuffer)
         {
             packet.isDelivered   = false;
             packet.DroppedReason = "New Agent reset";
             Node.updateStates(packet);
         }
     }
     AgentBuffer.Clear();
 }
コード例 #4
0
 public void AgentStorePacket(Packet packet)
 {
     initiateSinkOutOfRangeTimer();
     AgentBuffer.Enqueue(packet);
 }