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

            foreach (NeighborsTableEntry nei in RN.Node.NeighborsTable)
            {
                Sensor node     = nei.NeiNode;
                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.NeiNode, RN.AntiClockWiseNeighbor);
                    distance += Operations.DistanceBetweenTwoSensors(nei.NeiNode, RN.ClockWiseNeighbor);
                }
                RingNodeCandidates cand = new RingNodeCandidates(nei.NeiNode, distance);
                holder.Add(cand);
            }
            ClosestNodestoRN = holder.OrderBy(i => i.Distance).ToList();
            //Console.WriteLine("ASd");
        }
        private static void GetTheSetofClosestNodes(RingNodes RN)
        {
            ClosestNodestoRN.Clear();
            List <RingNodeCandidates> holder = new List <RingNodeCandidates>();

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