Example #1
0
        /// <summary>
        /// Calculates the position
        /// </summary>
        /// <param name="BlindNode">The BlindNode to be positioned</param>
        /// <returns>The position of the blind node</returns>
        public static Point CalculatePosition(Node BlindNode, Node.FilterMethod filterMethod)
        {
            Point position = new Point();
            double weight;
            double totalWeight = 0;

            foreach (AnchorNode an in BlindNode.Anchors)
            {
                an.fRSS = filterMethod(an.RSS);
            }

            foreach (AnchorNode anchorNode in BlindNode.Anchors)
            {
                weight = 1 / Math.Pow(anchorNode.fRSS, 3);
                position.x += anchorNode.posx * weight;
                position.y += anchorNode.posy * weight;

                totalWeight += weight;
            }

            position.x /= totalWeight;
            position.y /= totalWeight;

            return position;
        }
        public void ClusteredTriLaterationTest()
        {
            MySQLClass MyDB = new MySQLClass("DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;DATABASE=senseless;UID=root;PASSWORD=admin;OPTION=3;");

            Node BlindNode = new Node("Test", MyDB);
            BlindNode.NewAnchor("1", 50.00, 0.00, 0.00, 1);
            BlindNode.NewAnchor("2", 50.00, 2.00, 0.00, 1);
            BlindNode.NewAnchor("3", 50.00, 2.00, 2.00, 1);

            Node.FilterMethod filterMethod = RangeBasedPositioning.AverageFilter;
            Point expected = new Point(1,1);

            Point actual;

            actual = ClusterTrilateration.CalculatePosition(BlindNode, filterMethod, false);
            //Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }