コード例 #1
0
ファイル: PlantsPage.xaml.cs プロジェクト: ogcansat/OGSatApp
        private void PckrPlants_SelectedIndexChanged(object sender, EventArgs e)
        {
            TblSctnPlant.Clear();

            string[] columns = PlantsController.Plants.Columns;
            string[] values  = PlantsController.Plants.Lines.First(x => string.Equals(PlantsController.FormatPlantTitle(x), PckrPlants.SelectedItem.ToString()));

            GUIAnimations.FillTableSection(TblSctnPlant, columns, values);
        }
コード例 #2
0
ファイル: PlantsPage.xaml.cs プロジェクト: ogcansat/OGSatApp
        public PlantsPage()
        {
            InitializeComponent();

            if (GUIAnimations.CheckConnection(this))
            {
                return;
            }

            GetPlants();
        }
コード例 #3
0
ファイル: SatDataPage.xaml.cs プロジェクト: ogcansat/OGSatApp
        /// <summary>
        /// Initialize the page, create task for listening of data from RPi
        /// </summary>
        public SatDataPage()
        {
            InitializeComponent();

            if (GUIAnimations.CheckConnection(this))
            {
                return;
            }

            Disappearing += SatDataPage_Disappearing;

            _token = new CancellationTokenSource();



            //Sends query for listening satellite data.
            _ = BluetoothController.SendQueryToRPiAsync(Query.DataSatellite);

            Task.Run(async() =>
            {
                while (true)
                {
                    string data = await BluetoothController.ReadDataFromRPiAsync();
                    Dispatcher.BeginInvokeOnMainThread(() => GUIAnimations.UpdateData(data, new Dictionary <string, Label>()
                    {
                        { "MessageID", LblMessage },
                        { "Temperature", LblTemp },
                        { "Humidity", LblHum },
                        { "Pressure", LblPress },
                        { "Altitude", LblAlt },
                        { "Longitude", LblLong },
                        { "Latitude", LblLat }
                    }, LblUpdateTime));

                    //Cancellation operation
                    if (_token.Token.IsCancellationRequested)
                    {
                        await BluetoothController.ClearIncomeBuffer();
                        return;
                    }
                }
            });
        }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: ogcansat/OGSatApp
        private async void ImgShutdown_Tapped(object sender, EventArgs e)
        {
            if (GUIAnimations.CheckConnection(this))
            {
                return;
            }

            string result = await DisplayActionSheet("Vyberte akci", "Zrušit", "", "Vypnout RPi", "Resetovat RPi", "Resetovat data monitoring");

            switch (result)
            {
            case "Vypnout RPi":
                await BluetoothController.SendQueryToRPiAsync("shutdown");

                await Task.Delay(1_000);

                RefreshConnectionStatus();
                break;

            case "Resetovat RPi":
                await BluetoothController.SendQueryToRPiAsync("reboot");

                await Task.Delay(1_000);

                RefreshConnectionStatus();
                await Task.Delay(15_000);

                RefreshConnectionStatus();
                break;

            case "Resetovat data monitoring":
                await BluetoothController.SendQueryToRPiAsync("restartOG");

                await Task.Delay(1_000);

                break;
            }
        }
コード例 #5
0
        private async void BttnGetBPEJ_Clicked(object sender, EventArgs e)
        {
            if (GUIAnimations.CheckConnection(this))
            {
                return;
            }

            BttnGetBPEJ.IsEnabled = false;

            var token = GUIAnimations.DotLoadingAnimation(LblBPEJFinding, "Vyhodnocování", 7, 300);

            Location location = null;

            try
            {
                location = await Geolocation.GetLocationAsync();

                EntrBPEJcode.Text = await BluetoothController.GetDataFromRPiAsync($"get_bpej {location.Longitude} {location.Latitude}", 1000, 1000);

                EntrBPEJcode_Completed(null, null);
            }
            catch (FeatureNotEnabledException)
            {
                _ = DisplayAlert("Lokace není povolená", "Pro použití funkce si povolte lokaci v telefonu.", "OK");
            }
            catch (Exception ex)
            {
                _ = DisplayAlert("Debug - Exception", ex.Message, "OK");
            }

            token.Cancel();
            await Task.Delay(500);

            LblBPEJFinding.Text = location != null ? $"Vaše pozice | z. délka: {location.Longitude}, z. šířka: {location.Latitude}" : "Vaši pozici se nepodařilo lokalizovat.";

            BttnGetBPEJ.IsEnabled = true;
        }
コード例 #6
0
        private async void EntrBPEJcode_Completed(object sender, EventArgs e)
        {
            // _ = ViewExtensions.RelRotateTo(ImgLoadingInfoBPEJ, 2800, 10000);

            if (GUIAnimations.CheckConnection(this))
            {
                return;
            }

            PrgrssBrBPEJ.IsVisible = true;
            PrgrssBrBPEJ.Progress  = 0;
            TblSctnPlants.Clear();
            TblSctnClimate.Clear();
            TblSctnInclination.Clear();
            TblSctnSoilDepth.Clear();
            TblSctnSoilUnit.Clear();
            BttnGetBPEJ.IsEnabled = false;

            _ = PrgrssBrBPEJ.ProgressTo(0.5, 23000, Easing.Linear);

            var data = await BluetoothController.GetDataFromRPiAsync("getBPEJ " + EntrBPEJcode.Text + " plants", 5000);

            GUIAnimations.FillTableSection(TblSctnPlants, data.Split('\n')[0].Split(';'), data.Split('\n')[1].Split(';'), async(s, a) =>
            {
                var plant = (((s as ViewCell).View as StackLayout).Children[0] as Label).Text;
                await Navigation.PushModalAsync(new PlantsPage(plant));
            });

            _ = PrgrssBrBPEJ.ProgressTo(0.6, 1250, Easing.Linear);

            data = await BluetoothController.GetDataFromRPiAsync("getBPEJ " + EntrBPEJcode.Text + " climate", 5000);

            GUIAnimations.FillTableSection(TblSctnClimate, data.Split('\n')[0].Split(';'), data.Split('\n')[1].Split(';'));

            _ = PrgrssBrBPEJ.ProgressTo(0.7, 1250, Easing.Linear);

            data = await BluetoothController.GetDataFromRPiAsync("getBPEJ " + EntrBPEJcode.Text + " inclination", 5000);

            GUIAnimations.FillTableSection(TblSctnInclination, data.Split('\n')[0].Split(';'), data.Split('\n')[1].Split(';'));

            _ = PrgrssBrBPEJ.ProgressTo(0.8, 1250, Easing.Linear);

            data = await BluetoothController.GetDataFromRPiAsync("getBPEJ " + EntrBPEJcode.Text + " soilDepth", 5000);

            GUIAnimations.FillTableSection(TblSctnSoilDepth, data.Split('\n')[0].Split(';'), data.Split('\n')[1].Split(';'));

            _ = PrgrssBrBPEJ.ProgressTo(0.9, 1250, Easing.Linear);

            data = await BluetoothController.GetDataFromRPiAsync("getBPEJ " + EntrBPEJcode.Text + " soilUnit", 5000);

            GUIAnimations.FillTableSection(TblSctnSoilUnit, data.Split('\n')[0].Split(';'), new string[] { String.Join("\n", data.Split('\n').Skip(1).ToArray()) });

            _ = PrgrssBrBPEJ.ProgressTo(1, 1250, Easing.Linear);

            PrgrssBrBPEJ.IsVisible = false;
            BttnGetBPEJ.IsEnabled  = true;


            /*GUIAnimations.FillTableSection(TblSctnPlants, data.Split('\n')[0].Split(';'), data.Split('\n')[1].Split(';'));
             * GUIAnimations.FillTableSection(TblSctnClimate, data.Split('\n')[2].Split(';'), data.Split('\n')[3].Split(';'));
             * GUIAnimations.FillTableSection(TblSctnInclination, data.Split('\n')[4].Split(';'), data.Split('\n')[5].Split(';'));
             * GUIAnimations.FillTableSection(TblSctnSoilDepth, data.Split('\n')[6].Split(';'), data.Split('\n')[7].Split(';'));
             * GUIAnimations.FillTableSection(TblSctnSoilUnit, data.Split('\n')[8].Split(';'), data.Split('\n')[9].Split(';'));*/


            //ViewExtensions.CancelAnimations(ImgLoadingInfoBPEJ);


            //data = await BPEJController.LoadBPEJDetailsAsync(CodeBPEJ.SoilUnit, int.Parse(EntrBPEJcode.Text.Substring(5, 2)), false);
            //FillTableSection(TblSctnSoilUnit, new string[] { "Kód", "Popis" }, new string[] { data.Item2[0], string.Join(Environment.NewLine, data.Item2.Skip(1)) });
        }