示例#1
0
        private void GetTheSetofClosestNodes(RingNodes RN)
        {
            ClosestNodestoRN.Clear();
            List <RingNodeCandidates> holder = new List <RingNodeCandidates>();
            Sensor anti  = RN.AntiClockWiseNeighbor;
            Sensor clock = RN.ClockWiseNeighbor;

            foreach (Sensor nei in RN.Node.NeighborsTable)
            {
                Sensor node     = nei;
                double distance = 0;
                if (Operations.isInMyComunicationRange(node, anti))
                {
                    distance += Operations.DistanceBetweenTwoSensors(node, clock);
                }
                else if (Operations.isInMyComunicationRange(node, clock))
                {
                    distance += Operations.DistanceBetweenTwoSensors(node, anti);
                }
                else
                {
                    distance  = Operations.DistanceBetweenTwoSensors(nei, RN.AntiClockWiseNeighbor);
                    distance += Operations.DistanceBetweenTwoSensors(nei, RN.ClockWiseNeighbor);
                }
                RingNodeCandidates cand = new RingNodeCandidates(nei, distance);
                holder.Add(cand);
            }
            ClosestNodestoRN = holder.OrderBy(i => i.Distance).ToList();
            //Console.WriteLine("ASd");
        }
示例#2
0
        private static void GetTheSetofClosestNodes(RingNodes RN)
        {
            ClosestNodestoRN.Clear();
            List <RingNodeCandidates> holder = new List <RingNodeCandidates>();

            foreach (Sensor nei in RN.Node.NeighborsTable)
            {
                double distance = Operations.DistanceBetweenTwoSensors(nei, RN.AntiClockWiseNeighbor);
                distance += Operations.DistanceBetweenTwoSensors(nei, RN.ClockWiseNeighbor);
                RingNodeCandidates cand = new RingNodeCandidates(nei, distance);
                holder.Add(cand);
            }
            ClosestNodestoRN = holder.OrderBy(i => i.Distance).ToList();
        }