Example #1
0
        static string UploadMembership(fuzzy_membership_created newData)
        {
            try
            {
                using (HttpClient client = new HttpClient())
                {
                    string              json        = JsonConvert.SerializeObject(newData);
                    HttpContent         contentPost = new StringContent(json, Encoding.UTF8, "application/json");
                    HttpResponseMessage res         = client.PutAsync("http://" + BaseUrl + "api/fuzzy_membership", contentPost).Result;

                    return(res.Content.ReadAsStringAsync().Result.ToString());
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            List <List <int> > RPs = new List <List <int> >();
            List <int>         N   = new List <int> {
            };
            List <int> M           = new List <int> {
            };
            List <int> F           = new List <int> {
            };

            RPs.Add(N);     //RPs[0] is Near Set
            RPs.Add(M);     //RPs[1] is Medium Set
            RPs.Add(F);     //RPs[2] is Far Set

            List <data_all>          DataRes    = new List <data_all>();
            List <fuzzy_label>       LabelRes   = new List <fuzzy_label>();
            fuzzy_membership_created uploadData = new fuzzy_membership_created();

            foreach (int AP in APs)
            {
                //N
                LabelRes.Clear();
                LabelRes = Get_fuzzy_label_N(AP);
                foreach (var data in LabelRes)
                {
                    RPs[0].Add(data.Position);
                }
                //RPs[0].ForEach(Console.Write);

                foreach (int Position in RPs[0])
                {
                    DataRes.Clear();
                    DataRes = Get_data_all_PosMinor(Position, AP);
                    foreach (var data in DataRes)
                    {
                        if (data.RSS <= 0)
                        {
                            allData.Add(data.RSS);
                        }
                    }
                }
                updateValue();
                Console.WriteLine("AP:" + AP.ToString() + "   N");
                Console.WriteLine("  S: " + allData.Count + "  S.D: " + sd + "  Mean: " + mean);

                uploadData.BeaconMinor = AP;
                uploadData.Label       = "N";
                uploadData.Samples     = allData.Count;
                uploadData.Max         = (int)Max;
                uploadData.Min         = (int)Min;
                uploadData.Mean        = mean;
                uploadData.SD          = sd;

                UploadMembership(uploadData);

                dataClear();
                RPs[0].Clear();

                Console.WriteLine();

                //M
                LabelRes.Clear();
                LabelRes = Get_fuzzy_label_M(AP);
                foreach (var data in LabelRes)
                {
                    RPs[1].Add(data.Position);
                }
                //RPs[1].ForEach(Console.Write);

                foreach (int Position in RPs[1])
                {
                    DataRes.Clear();
                    DataRes = Get_data_all_PosMinor(Position, AP);
                    foreach (var data in DataRes)
                    {
                        if (data.RSS <= 0)
                        {
                            allData.Add(data.RSS);
                        }
                    }
                }
                updateValue();
                Console.WriteLine("AP:" + AP.ToString() + "   M");
                Console.WriteLine("  S: " + allData.Count + "  S.D: " + sd + "  Mean: " + mean);

                uploadData.BeaconMinor = AP;
                uploadData.Label       = "M";
                uploadData.Samples     = allData.Count;
                uploadData.Max         = (int)Max;
                uploadData.Min         = (int)Min;
                uploadData.Mean        = mean;
                uploadData.SD          = sd;

                UploadMembership(uploadData);

                dataClear();
                RPs[1].Clear();

                Console.WriteLine();

                //F
                LabelRes.Clear();
                LabelRes = Get_fuzzy_label_F(AP);
                foreach (var data in LabelRes)
                {
                    RPs[2].Add(data.Position);
                }
                RPs[2].ForEach(Console.Write);

                foreach (int Position in RPs[2])
                {
                    DataRes.Clear();
                    DataRes = Get_data_all_PosMinor(Position, AP);
                    foreach (var data in DataRes)
                    {
                        if (data.RSS <= 0)
                        {
                            allData.Add(data.RSS);
                        }
                    }
                }
                updateValue();
                Console.WriteLine("AP:" + AP.ToString() + "   F");
                Console.WriteLine("  S: " + allData.Count + "  S.D: " + sd + "  Mean: " + mean);

                uploadData.BeaconMinor = AP;
                uploadData.Label       = "F";
                uploadData.Samples     = allData.Count;
                uploadData.Max         = (int)Max;
                uploadData.Min         = (int)Min;
                uploadData.Mean        = mean;
                uploadData.SD          = sd;

                UploadMembership(uploadData);

                dataClear();
                RPs[2].Clear();

                Console.WriteLine();
            }

            Console.WriteLine("Finished, Press Any Key to stop the program");
            Console.ReadKey();
        }