コード例 #1
0
        /// <summary>
        /// Első eset: a két távolság által jelzett kör messze van egymástól:
        /// Megoldás: mindkettőt arányosan növeljük
        /// </summary>
        protected bool CheckFarDistances(NearbyBluetoothTag tag1, NearbyBluetoothTag tag2)
        {
            if (LocationCalculator.Distance(tag1.Origo, tag2.Origo) > tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag)
            {
                double deviance = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag);
                deviance += BIAS;  // Az eltérés torzítása, így biztosan lesz metszéspont
                double max   = tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag;
                double rate1 = tag1.AveragePredictedDistanceFromTag / max;
                double rate2 = tag2.AveragePredictedDistanceFromTag / max;
                tag1.SetAveragePredictedDistance(tag1.AveragePredictedDistanceFromTag + deviance * rate1);
                tag2.SetAveragePredictedDistance(tag2.AveragePredictedDistanceFromTag + deviance * rate2);


                //TEST
                double dist = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag);
                if (dist > 0.0)
                {
                    dist = 0; /* throw new Exception("Calculation error: distance must be 0.0"); */
                }
                //TEST

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        public void BeaconReceived(NearbyBluetoothTag Sender, int RSSI)
        {
            /*
             * RssiMeasure rssi = distanceMeasureHelper.GetRSSI(RSSI);
             * double distance = rssi.DistanceAverage;
             *
             * RssiMeasure avgrssi = distanceMeasureHelper.GetRSSI(AverageRSSI);
             * double avgdistance = avgrssi.DistanceAverage;
             */
            double distance    = distcalc.GetDistanceByRSSI(RSSI);
            double avgdistance = distcalc.GetDistanceByRSSI(Sender.AverageRSSI);

            Sender.SetAveragePredictedDistance(avgdistance);

            foreach (BluetoothTagDisplay tag in tags)
            {
                if (tag.MAC.Equals(Sender.MAC))
                {
                    tag.BeaconSent(RSSI, distance, Sender.AverageRSSI, avgdistance);
                }
            }

            LocationResult location = PredictPosition();

            mainWindow.Dispatcher.Invoke((Action)(() =>
            {
                DrawSimulatedPosition(location);
            }));
        }
コード例 #3
0
        public void BeaconReceived(NearbyBluetoothTag Sender, int RSSI)
        {
            /*
            RssiMeasure rssi = distanceMeasureHelper.GetRSSI(RSSI);
            double distance = rssi.DistanceAverage;

            RssiMeasure avgrssi = distanceMeasureHelper.GetRSSI(AverageRSSI);
            double avgdistance = avgrssi.DistanceAverage;
            */
            double distance = distcalc.GetDistanceByRSSI(RSSI);
            double avgdistance = distcalc.GetDistanceByRSSI(Sender.AverageRSSI);
            Sender.SetAveragePredictedDistance(avgdistance);

            foreach (BluetoothTagDisplay tag in tags)
            {
                if (tag.MAC.Equals(Sender.MAC))
                {
                    tag.BeaconSent(RSSI, distance, Sender.AverageRSSI, avgdistance);
                }
            }
                        
            LocationResult location = PredictPosition();
            mainWindow.Dispatcher.Invoke((Action)(() =>
            {
                DrawSimulatedPosition(location);
            }));
        }
コード例 #4
0
        /// <summary>
        /// Első eset: a két távolság által jelzett kör messze van egymástól:
        /// Megoldás: mindkettőt arányosan növeljük
        /// </summary>
        protected bool CheckFarDistances(NearbyBluetoothTag tag1, NearbyBluetoothTag tag2)
        {
            if (LocationCalculator.Distance(tag1.Origo, tag2.Origo) > tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag)
            {
                double deviance = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag);
                deviance += BIAS;  // Az eltérés torzítása, így biztosan lesz metszéspont
                double max = tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag;
                double rate1 = tag1.AveragePredictedDistanceFromTag / max;
                double rate2 = tag2.AveragePredictedDistanceFromTag / max;
                tag1.SetAveragePredictedDistance(tag1.AveragePredictedDistanceFromTag + deviance * rate1);
                tag2.SetAveragePredictedDistance(tag2.AveragePredictedDistanceFromTag + deviance * rate2);


                //TEST
                double dist = LocationCalculator.Distance(tag1.Origo, tag2.Origo) - (tag1.AveragePredictedDistanceFromTag + tag2.AveragePredictedDistanceFromTag);
                if (dist > 0.0)
                    dist = 0; /* throw new Exception("Calculation error: distance must be 0.0"); */
                //TEST

                return true;
            }
            else return false;
        }