Exemplo n.º 1
0
        private async void NewBatteryButton_Click(object sender, RoutedEventArgs e)
        {
            Battery          _newBattery          = new Battery();
            BatteryViewModel _newBatteryViewModel = new BatteryViewModel(_newBattery);

            _newBatteryViewModel.IsNewBattery = true;

            _newBatteryViewModel.Name     = newBatteryName.Text;
            _newBatteryViewModel.Voltage  = float.Parse(newBatteryVoltage.Text, CultureInfo.InvariantCulture.NumberFormat);
            _newBatteryViewModel.Capacity = Convert.ToInt32(newBatteryCapacity.Text);
            _newBatteryViewModel.InitInternalImpedance = Convert.ToInt32(newBatteryImpedence.Text);
            _newBatteryViewModel.NominalCycleLife      = Convert.ToInt32(newBatteryCycleLife.Text);

            NewBatteryFlyout.Hide();

            await _newBatteryViewModel.SaveBatteryAsync();



            // Show notification of new Battery has been saved successfully
            int duration = 2000;

            NewBatteryNotification.Show("New Battery has been saved successfully", duration);
        }
Exemplo n.º 2
0
        public async void TimeCountStop()
        {
            timer4Stopwatch.Stop();
            timer4Stopwatch.Tick -= TimerTicking;
            stopwatch.Stop();


            float _changedCapacity = (float)(rand.Next(1, 10) / 20.0);
            int   offsetIndex      = rand.Next(offset.Length);

            await Task.Run(() => AddNewTestResult(offset[offsetIndex], _changedCapacity));

            ChargingProgressBar.Foreground = Application.Current.Resources["GBatteriesAccentColorBrush"] as Brush;
            ChargingMinutes.Foreground     = Application.Current.Resources["GBatteriesAccentColorBrush"] as Brush;
            ChargingProgress.Foreground    = Application.Current.Resources["GBatteriesAccentColorBrush"] as Brush;

            selectedBattery.PerformedCycle++;
            await selectedBattery.SaveBatteryAsync();

            string _testResult = $"TEST RESULT : \n\tCharging Times : {ChargingMinutes.Text} \n\tChanged Battery Capacity : {offset[offsetIndex]}{_changedCapacity}\n\t Average of Ambient Temperature : {TempTemperaure/TestDataIndex}℃";


            var messageDialog = new MessageDialog(_testResult);


            // Add commands and set their command ids
            messageDialog.Commands.Add(new UICommand("Go history page", null, 0));
            messageDialog.Commands.Add(new UICommand("Test again with the current setting", null, 1));
            messageDialog.Commands.Add(new UICommand("New test", null, 2));
            // Show the message dialog
            var commandChosen = await messageDialog.ShowAsync();

            if (commandChosen.Id is 0)
            {
                AppShell.CurrentPage.AppFrame.Navigate(typeof(HistoryPage));
                //add to new history
            }
            else
            {
                ChargingMinutes.Text      = "00:00:00.00";
                ChargingProgress.Text     = "0%";
                ChargingProgressBar.Value = 0;

                if (commandChosen.Id is 2)
                {
                    TextDate.Text                 = String.Empty;
                    TextExperimenter.Text         = String.Empty;
                    TextBatteryName.Text          = String.Empty;
                    TextFastTypeCharge.Text       = String.Empty;
                    TextPulseMode.Text            = String.Empty;
                    TextCapacity.Text             = String.Empty;
                    TextVoltage.Text              = String.Empty;
                    TextImpedance.Text            = String.Empty;
                    TextCyclelife.Text            = String.Empty;
                    TextCurrentCycle.Text         = String.Empty;
                    TextDOD.Visibility            = Visibility.Collapsed;
                    TextPulseModeLabel.Foreground = new SolidColorBrush(Windows.UI.Colors.Gray);
                    TextPulseMode.Visibility      = Visibility.Collapsed;

                    ComboboxBattery.SelectedItem      = null;
                    ComboBoxExperimenter.SelectedItem = null;
                    ComboBoxChargeType.SelectedItem   = null;
                    ComboBoxPulseMode.SelectedItem    = null;
                }
                else
                {
                    TextCurrentCycle.Text = " " + selectedBattery.PerformedCycle.ToString();
                }
            }

            TestDataIndex  = 0;
            TempTemperaure = 0;
        }