Esempio n. 1
0
 private void OnFlowChange(object sender, MeasurementChangedEventArgs e)
 {
     //lock (LastMeasurement)
     //{
     //    int change = LastMeasurement.CompareTo(e.Measurement);
     //    if (change == 0)
     //        return;
     Debug.WriteLine($"{e.GetType().Name}: {e.Measurement}");
     LastMeasurement.Amount = e.Measurement.Amount;
     //}
 }
        private async void OnWeightChange(object sender, MeasurementChangedEventArgs e)
        {
            Debug.WriteLine($"{e.GetType().Name}: {e.Measurement}");
            //1 pint = 16 Ounces
            //MaxKegVolume
            //62 = 100%
            //float percentage = e.Measurement.Amount*10 / (Common.KegSettings.MaxKegWeight - Common.KegSettings.EmptyKegWeight);
            float percentage = e.Measurement.Amount / (Common.KegSettings.MaxKegWeight - Common.KegSettings.EmptyKegWeight);

            Debug.WriteLine($"Percentage2: {percentage}");

            await MainPageDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                try
                {
                    this.warningTitle.Visibility = Visibility.Collapsed;
                    if (percentage > 100.00f)
                    {
                        PintsText.Text = $"99% full";
                    }
                    else
                    {
                        PintsText.Text = $"{ Math.Round(percentage)}% full";
                    }

                    if (percentage < Common.MINIMUMLIMITTOEMPTY)
                    {
                        //this.startScanTitle.Text = string.Format(Common.GetResourceText("Page1KegEmpty"));
                        this.warningTitle.Visibility        = Visibility.Visible;
                        this.warningTitle.Text              = string.Format(this["Page1KegEmpty"]);
                        this.WarningBorderBrush.BorderBrush = App.Current.Resources["BorderBrush"] as SolidColorBrush;

                        this.PintsText.Foreground = App.Current.Resources["BorderBrush"] as SolidColorBrush;
                    }
                }
                catch
                {
                    PintsText.Text = $"--";
                }
            });
        }
Esempio n. 3
0
        private async void OnTemperatureChange(object sender, MeasurementChangedEventArgs e)
        {
            await MainPageDispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                if (e.Measurement != null)
                {
#if DEBUG
                    Debug.WriteLine($"OnTemperatureChange:{e.GetType().Name}: {e.Measurement}");
#endif
                    tempeUnitsToggle = !tempeUnitsToggle;
                    if (tempeUnitsToggle)
                    {
                        //Celsius
                        TemperatureText.Text = $"{ ((e.Measurement.Amount -32) * 5 / 9):N}° Celsius";
                    }
                    else
                    {
                        TemperatureText.Text = $"{e.Measurement.Amount:N}° {e.Measurement.Units}";
                    }

                    //Debug.WriteLine("Temp:" + TemperatureText.Text);

                    if (e.Measurement.Amount >= Common.MaxTempInsideKeg)
                    {
                        this.TemperatureText.Foreground = App.Current.Resources["BorderBrush"] as SolidColorBrush;
                    }
                    else
                    {
                        this.TemperatureText.Foreground = App.Current.Resources["ForegroundColor"] as SolidColorBrush;
                    }
                }
                else
                {
                    TemperatureText.Text = $"-°-";
                }
            });
        }
Esempio n. 4
0
        internal async void OnFlowChange(object sender, MeasurementChangedEventArgs e)
        {
            await Page2Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
            {
                try
                {
                    Debug.WriteLine($"Prior: {e.GetType().Name}: {e.Measurement}");

                    if (e.Measurement != null && e.Measurement.Amount > 0.0f && e.Measurement.Amount > lastMeasurement)
                    {
                        Debug.WriteLine($"****: {e.GetType().Name}: {e.Measurement} ****");
                        lastMeasurement = e.Measurement.Amount;

                        Counter = Common.COUNTERSHORTWAIT;

                        if (!timer.IsEnabled)
                        {
                            Reset(false);
                        }
                        else
                        {
                            timer.Stop();
                            timer.Start();
                        }

                        //HidePopupCounter();

                        AllowedLimitFill(e.Measurement.Amount);

                        //Check user max limit
                        if ((totalConsumption + e.Measurement.Amount) >= Common.KegSettings.MaxUserOuncesPerHour)
                        {
                            //Cut-off user
                            App._flowControl.IsActive = false;

                            // If Limit Reached, display required text
                            this.Page2Part1Text.Text = Common.GetResourceText("Page2LimitSorryText");
                            this.Page2Part2Text.Text = Common.GetResourceText("Page2LimitReachedText");
                            this.Page2Image.Source   = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/no-beer.png"));

                            //TODO:
                            //Better to show message in popup about why user need to exit
                            //String: Page2LimitReachedText
                        }
                        else
                        {
                            if (!imageLoaded)
                            {
                                //Start Pouring:
                                this.Page2Part1Text.Text = Common.GetResourceText("Page2SuccessValidationText");
                                this.Page2Part2Text.Text = Common.GetResourceText("Page2SuccessStart");
                                this.Page2Image.Source   = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/beer.gif"));
                                imageLoaded = true;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    KegLogger.KegLogException(ex, "Page2:OnFlowChanged", SeverityLevel.Error);

                    KegLogger.KegLogTrace(ex.Message, "Page2:OnFlowChanged", SeverityLevel.Error,
                                          new Dictionary <string, string>()
                    {
                        { "Measurement", e.Measurement != null ? e.Measurement.Amount.ToString(): string.Empty }
                    });
                }
            });
        }