private async void MyMap_Loaded(object sender, RoutedEventArgs e)
        {
            disablePanel();
            PopupLoading.IsOpen = true;
            // Specify a known location
            BasicGeoposition cityPosition = new BasicGeoposition()
            {
                Latitude = 47.604, Longitude = -122.329
            };
            Geopoint cityCenter = new Geopoint(cityPosition);

            map.Center = cityCenter;
            Geopoint pos = await MapHelper.Locate();

            if (pos != null)
            {
                map.Center = pos;
                await UploadFunctions.UploadPosition(pos.Position.Longitude, pos.Position.Latitude);

                MapHelper.AddILocationIcon(map);
                BasicGeoposition startLocation = new BasicGeoposition {
                    Longitude = pos.Position.Longitude, Latitude = pos.Position.Latitude
                };
                BasicGeoposition endLocation = await GetHomePosition();

                MapHelper.ShowRoute(map, startLocation, endLocation);
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Count not get the location!");
                await dialog.ShowAsync();
            }
            PopupLoading.IsOpen = false;
            enablePanel();
        }
Exemple #2
0
        private async void btn_send_onClicked(object sender, RoutedEventArgs e)
        {
            input_message.IsEnabled = false;
            btn_send.IsEnabled      = false;
            btn_send.Content        = "Sending";
            if (input_message.Text.Trim() != "")
            {
                string result = await UploadFunctions.UploadRemind(input_message.Text.Trim());

                System.Diagnostics.Debug.WriteLine(result);
                if (result != "")
                {
                    await new MessageDialog(result).ShowAsync();
                }
                RemindEntity remind = new RemindEntity()
                {
                    MessageType = RemindEntity.MsgType.To, Content = input_message.Text.Trim()
                };
                MainPage.notification.Data_list_remind.Add(remind);
                input_message.Text = "";
            }
            input_message.IsEnabled = true;
            btn_send.IsEnabled      = true;
            btn_send.Content        = "Send";
        }
Exemple #3
0
        private async void onNoClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            string username = LocalSettingsHelper.GetUsername();

            if (username != null)
            {
                await UploadFunctions.UploadBindRelationInfo(username, childname, "no");
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Null Username!");
                await dialog.ShowAsync();
            }
        }
        private async void btn_health_onClicked(object sender, RoutedEventArgs e)
        {
            //await UploadFunctions.UploadTemperature(37.8);
            // await UploadFunctions.UploadHeartbeat(34);
            DailyDetail detail_dining = new DailyDetail {
                time = 3, detail = new List <string> {
                    "07:43 - 08:11", "12:10 - 12:42", "17:06 - 17:34"
                }, comment = "diet condition is good."
            };
            DailyDetail detail_sleep = new DailyDetail {
                time = 1, detail = new List <string> {
                    "22:10 - 8:31"
                }, comment = "sleeping time is too long, please develop a health living habit."
            };
            DailyDetail detail_toilet = new DailyDetail {
                time = 4, detail = new List <string> {
                    "09:43 - 10:21"
                }, comment = "lavatory condition is abnormal, please pay attention to his/her diet habit, eat more fruit and vegetables."
            };
            DailyDetail detail_parlour = new DailyDetail {
                time = 2, detail = new List <string> {
                    "08:40 - 09:38", "14:03 - 15:22"
                }, comment = "parlour condition is good."
            };
            DailyDetail detail_outdoor = new DailyDetail {
                time = 1, detail = new List <string> {
                    "10:30 - 11:10"
                }, comment = "Outdoor exercise time is too short, Strongly recommend him/her do more exercises after meals."
            };


            //  Util.ObjectToJsonData(detail_dining)
            string result = await UploadFunctions.UploadDaily(2.7, Util.ObjectToJsonData(detail_dining), 10.2, Util.ObjectToJsonData(detail_sleep), 1.3, Util.ObjectToJsonData(detail_toilet), 8.4, Util.ObjectToJsonData(detail_parlour), 0.7, Util.ObjectToJsonData(detail_outdoor));

            // await UploadFunctions.UploadPosition(108.232591096998, 34.5341);
            //await UploadFunctions.UploadIndoorPosition("C");
            //  System.Diagnostics.Debug.WriteLine("result:" + result);
            this.Frame.Navigate(typeof(HealthPage));
        }
        //接受蓝牙数据并校验进行上传
        public async void CharacteristicValueChanged_Handler(GattCharacteristic sender, GattValueChangedEventArgs obj)
        {
            str = ParseString(obj.CharacteristicValue);
            Debug.WriteLine(str);
            if (Util.IsRecieveDataVaild(str))
            {
                //校验心跳数据,如果相同数据收到5次及以上则上传数据
                int rate = Util.GetHeartRateFromBluetoothRecieve(str);
                if (rate != 0)
                {
                    if (data_rate != rate)
                    {
                        data_rate  = rate;
                        count_rate = 0;
                    }
                    else
                    {
                        count_rate++;
                        if (count_rate >= 5)
                        {
                            Debug.WriteLine(await UploadFunctions.UploadHeartbeat(rate));
                            count_rate = 0;
                        }
                    }
                }
                //校验体温数据,如果相同数据收到5次及以上则上传数据
                double temp = Util.GetTemperatureFromBluetoothRecieve(str);
                if (temp != 0)
                {
                    if (data_temp != temp)
                    {
                        data_temp  = temp;
                        count_temp = 0;
                    }
                    else
                    {
                        count_temp++;
                        if (count_temp >= 5)
                        {
                            Debug.WriteLine(await UploadFunctions.UploadTemperature(temp));
                            count_temp = 0;
                        }
                    }
                }
                //校验房间数据,如果相同数据收到5次及以上,则上传数据
                if (Util.GetRoomFromBluetoothRecieve(str) != null && Util.GetRoomFromBluetoothRecieve(str) != "S")
                {
                    string room_r = Util.GetRoomFromBluetoothRecieve(str);
                    if (room != room_r)
                    {
                        // room = (room == room_r) ? room : room_r;
                        room       = room_r;
                        count_room = 0;
                    }
                    else
                    {
                        count_room++;
                        if (count_room >= 35)
                        {
                            Debug.WriteLine(await UploadFunctions.UploadIndoorPosition(room));
                            if (room == "B")
                            {
                                //开始记录如厕次数
                                //  LocalSettingsHelper.SetLavatoryStartTime();
                                if (!isInLavatory)
                                {
                                    Debug.WriteLine(await UploadFunctions.UploadSleepInfo("go to the Lavatory"));
                                }
                                isInLavatory = true;
                            }

                            //string dining = LocalSettingsHelper.GetDailyTime("dining");
                            //string dining_detail = LocalSettingsHelper.GetDailyDetail("dining_detail");
                            //string sleep = LocalSettingsHelper.GetDailyTime("sleep");
                            //string sleep_detail = LocalSettingsHelper.GetDailyDetail("sleep_detail");
                            //string toilet = LocalSettingsHelper.GetDailyTime("toilet");
                            //string toilet_detail = LocalSettingsHelper.GetDailyDetail("toilet_detail");
                            //string parlour = LocalSettingsHelper.GetDailyTime("parlour");
                            //string parlour_detail = LocalSettingsHelper.GetDailyDetail("parlour_detail");
                            //string outdoor = LocalSettingsHelper.GetDailyTime("outdoor");
                            //string outdoor_detail = LocalSettingsHelper.GetDailyDetail("outdoor_detail");

                            ////将如厕时间记录到日常中
                            //LocalSettingsHelper.SetDailyTime("toilet", toiletTime.ToString());
                            //DailyDetail toiletDetail = Util.DataContractJsonDeSerializer<DailyDetail>(toilet_detail);
                            //toiletDetail.time += 1;
                            //if (toiletDetail.time > 3)
                            //{
                            //    toiletDetail.comment = "too many times during the day.   It is the urination phenomenon.  Please pay more attention to him/her.  Strongly recommend you to take him/her to do physical examination in order to prevent the potential severity disease.";
                            //}
                            //toiletDetail.detail.Add(Util.GetTimeFromDateTime(LocalSettingsHelper.GetLavatoryStartTime()) + " - " + Util.GetTimeFromDateTime(DateTime.Now));
                            //string toiletJsonString = Util.ObjectToJsonData(toiletDetail);
                            //LocalSettingsHelper.SetDailyDetail("toilet_detail", toiletJsonString);

                            //上传如厕次数和详情
                            //  Debug.WriteLine(UploadFunctions.UploadDaily(dining, dining_detail, sleep, sleep_detail, LocalSettingsHelper.GetDailyTime("toilet"), toiletJsonString, parlour, parlour_detail, outdoor, outdoor_detail));

                            count_room = 0;
                        }
                        if (Util.GetLavatoryNullFromRecieve(str))
                        {
                            if (isInLavatory)
                            {
                                isInLavatory = false;
                                Debug.WriteLine(await UploadFunctions.UploadIndoorPosition("H"));
                            }
                        }

                        //if (room_r != null && room_r != "B")
                        //{
                        //    if (isInLavatory)
                        //    {
                        //        isInLavatory = false;
                        //        TimeSpan toiletTime = DateTime.Now - LocalSettingsHelper.GetLavatoryStartTime();

                        //        LocalSettingsHelper.KEY_TOILET += toiletTime;
                        //        DailyDetail lavatoryDetail;
                        //        if (LocalSettingsHelper.KEY_TOILET_DETAIL != null && LocalSettingsHelper.KEY_TOILET_DETAIL != "")
                        //        {
                        //            lavatoryDetail = Util.DataContractJsonDeSerializer<DailyDetail>(LocalSettingsHelper.KEY_TOILET_DETAIL);
                        //        }
                        //        else
                        //        {
                        //            lavatoryDetail = new DailyDetail();
                        //        }
                        //        try
                        //        {
                        //            lavatoryDetail.time += 1;
                        //            details_lavatory.Add(Util.GetTimeFromDateTime(LocalSettingsHelper.GetLavatoryStartTime()) + " - " + Util.GetTimeFromDateTime(DateTime.Now));
                        //            lavatoryDetail.detail = details_lavatory;
                        //            if (lavatoryDetail.time > 3)
                        //            {
                        //                lavatoryDetail.comment = "too many times during the day.   It is the urination phenomenon.  Please pay more attention to him/her.  Strongly recommend you to take him/her to do physical examination in order to prevent the potential severity disease.";
                        //            }
                        //            else
                        //            {
                        //                lavatoryDetail.comment = "lavatory condition is normal";
                        //            }

                        //            string lavatoryJsonString = Util.ObjectToJsonData(lavatoryDetail);
                        //            LocalSettingsHelper.KEY_TOILET_DETAIL = lavatoryJsonString;

                        //            //上传睡眠次数和详情
                        //            Debug.WriteLine(UploadFunctions.UploadDaily(LocalSettingsHelper.KEY_DINING, LocalSettingsHelper.KEY_DINING_DETAIL, LocalSettingsHelper.KEY_SLEEP, LocalSettingsHelper.KEY_SLEEP_DETAIL, LocalSettingsHelper.KEY_TOILET, LocalSettingsHelper.KEY_TOILET_DETAIL, LocalSettingsHelper.KEY_PARLOUR, LocalSettingsHelper.KEY_PARLOUR_DETAIL, LocalSettingsHelper.KEY_OUTDOOR, LocalSettingsHelper.KEY_OUTDOOR_DETAIL));
                        //        }
                        //        catch (Exception e)
                        //        {
                        //            Debug.WriteLine("Lavatory : " + e.Message);
                        //        }
                        //   }
                        // }
                    }
                }
                //校验摔倒数据,如果相同数据收到5次及以上,则上传数据
                if (Util.GetTripFromBluetoothRecieve(str))
                {
                    count_trip++;
                    if (count_trip >= 5)
                    {
                        string place = string.Empty;
                        switch (room)
                        {
                        case "W":
                            place = "bedroom";
                            break;

                        case "C":
                            place = "diningroom";
                            break;

                        case "K":
                            place = "parlour";
                            break;

                        case "B":
                            place = "toilet";
                            break;
                        }
                        if (room == string.Empty || room == "")
                        {
                            Debug.WriteLine(await UploadFunctions.UploadTripInfo("outdoor"));
                        }
                        else
                        {
                            Debug.WriteLine(await UploadFunctions.UploadTripInfo(place));
                        }
                        count_trip = 0;
                    }
                }
                else
                {
                    count_trip = 0;
                }
                //校验入睡数据,如果数据收到5次及以上则上传数据
                if (str.Contains("J"))
                {
                    count_sleep++;
                    if (count_sleep >= 10)
                    {
                        count_sleep = 0;
                        //   isSleeped = true;
                        //try
                        //{
                        //    //开始记录睡眠时间
                        //    LocalSettingsHelper.SetStartSleepTime();
                        //}
                        //catch (Exception e)
                        //{
                        //    Debug.WriteLine("RecordSleep: " + e.Message);
                        //}
                        //上传入睡信息
                        Debug.WriteLine(await UploadFunctions.UploadSleepInfo("sleeped"));
                        await UploadFunctions.UploadIndoorPosition("J");
                    }
                }
                else
                {
                    count_sleep = 0;
                }
                //校验起床数据,如果数据收到5次及以上则上传数据
                if (str.Contains("Q"))
                {
                    count_getup++;
                    if (count_getup >= 3)
                    {
                        count_getup = 0;
                        //if (isSleeped)
                        //{
                        //    //开始记录睡眠时间
                        //    if (LocalSettingsHelper.GetSleepStartTime() != DateTime.MinValue)
                        //    {
                        //        TimeSpan sleepTime = DateTime.Now - LocalSettingsHelper.GetSleepStartTime();

                        //        //string dining = LocalSettingsHelper.GetDailyTime("dining");
                        //        //string dining_detail = LocalSettingsHelper.GetDailyDetail("dining_detail");
                        //        //string sleep = LocalSettingsHelper.GetDailyTime("sleep");
                        //        //string sleep_detail = LocalSettingsHelper.GetDailyDetail("sleep_detail");
                        //        //string toilet = LocalSettingsHelper.GetDailyTime("toilet");
                        //        //string toilet_detail = LocalSettingsHelper.GetDailyDetail("toilet_detail");
                        //        //string parlour = LocalSettingsHelper.GetDailyTime("parlour");
                        //        //string parlour_detail = LocalSettingsHelper.GetDailyDetail("parlour_detail");
                        //        //string outdoor = LocalSettingsHelper.GetDailyTime("outdoor");
                        //        //string outdoor_detail = LocalSettingsHelper.GetDailyDetail("outdoor_detail");

                        //        ////将睡觉时间记录到日常中
                        //        //LocalSettingsHelper.SetDailyTime("sleep", sleepTime.ToString());
                        //        LocalSettingsHelper.KEY_SLEEP += sleepTime;
                        //        DailyDetail sleepDetail;
                        //        if (LocalSettingsHelper.KEY_SLEEP_DETAIL != null && LocalSettingsHelper.KEY_SLEEP_DETAIL != "")
                        //        {
                        //            sleepDetail = Util.DataContractJsonDeSerializer<DailyDetail>(LocalSettingsHelper.KEY_SLEEP_DETAIL);
                        //        }
                        //        else
                        //        {
                        //            sleepDetail = new DailyDetail();
                        //        }
                        //        try
                        //        {
                        //            sleepDetail.time += 1;
                        //            details_sleep.Add(Util.GetTimeFromDateTime(LocalSettingsHelper.GetSleepStartTime()) + " - " + Util.GetTimeFromDateTime(DateTime.Now));
                        //            sleepDetail.detail = details_sleep;
                        //            sleepDetail.comment = "Sleeping condition is normal";

                        //            string sleepJsonString = Util.ObjectToJsonData(sleepDetail);
                        //            LocalSettingsHelper.KEY_SLEEP_DETAIL = sleepJsonString;

                        //LocalSettingsHelper.SetDailyDetail("sleep_detail", sleepJsonString);

                        //上传睡眠次数和详情
                        //           //Debug.WriteLine(UploadFunctions.UploadDaily(dining, dining_detail, LocalSettingsHelper.GetDailyTime("sleep"), sleepJsonString, toilet, toilet_detail, parlour, parlour_detail, outdoor, outdoor_detail));
                        //           Debug.WriteLine(UploadFunctions.UploadDaily(LocalSettingsHelper.KEY_DINING, LocalSettingsHelper.KEY_DINING_DETAIL, LocalSettingsHelper.KEY_SLEEP, LocalSettingsHelper.KEY_SLEEP_DETAIL, LocalSettingsHelper.KEY_TOILET, LocalSettingsHelper.KEY_TOILET_DETAIL, LocalSettingsHelper.KEY_PARLOUR, LocalSettingsHelper.KEY_PARLOUR_DETAIL, LocalSettingsHelper.KEY_OUTDOOR, LocalSettingsHelper.KEY_OUTDOOR_DETAIL));

                        //清空睡眠开始时间
                        // LocalSettingsHelper.ClearStartSleepTime();
                        //TODO 上传入睡数据
                        Debug.WriteLine(await UploadFunctions.UploadSleepInfo("get up"));
                        await UploadFunctions.UploadIndoorPosition("Q");

                        //}
                        //catch (Exception e)
                        //{
                        //    Debug.WriteLine("GetUp: " + e.Message);
                        //}
                        //}
                        //else
                        //{
                        //    Debug.WriteLine("Start time is null!");
                        //}
                        //isSleeped = false;
                        // }
                    }
                }
                else
                {
                    count_getup = 0;
                }
            }
        }
        private async void abb_bind_onClicked(object sender, RoutedEventArgs e)
        {
            string result = await UploadFunctions.UploadRequestBindRelationInfo(usernameInput.Text.Trim());

            System.Diagnostics.Debug.WriteLine(result);
        }