Ejemplo n.º 1
0
        /// <summary>
        /// нажата кнопка Старт
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void StartButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            Mutex GPIOButtonsAccessMutex = new Mutex(true, "GPIOButtonsAccessMutex", out bool mutexcreated);

            if (!mutexcreated)
            {
                try
                {
                    GPIOButtonsAccessMutex.WaitOne();
                }
                catch
                {
                }
            }
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                try
                {
                    switch (CurrentState)
                    {
                    case States.ReadyToDispenseWater:
                    {
                        WaterValvePin.Write(GpioPinValue.Low);
                        PumpPin.Write(GpioPinValue.Low);
                        StartLEDPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.Low);
                        ReadyToStartPage.ChangeWaterValveStatus(true);
                        AddItemToLogBox("Кнопка \"Старт\" нажата в контексте продажи, кран открыт, насос включен");
                        break;
                    }

                    case States.ServiceMode:
                    {
                        WaterValvePin.Write(GpioPinValue.Low);
                        PumpPin.Write(GpioPinValue.Low);
                        StartLEDPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.Low);
                        ReadyToStartPage.ChangeWaterValveStatus(true);
                        AddItemToLogBox("Кнопка \"Старт\" нажата в контексте служебного режима, кран открыт, насос включен");
                        break;
                    }

                    default:
                    {
                        AddItemToLogBox("Кнопка \"Старт\" нажата вне контекста продажи или служебного режима, действий не требуется");
                        break;
                    }
                    }
                }
                catch
                {
                }
                finally
                {
                }
            }
            GPIOButtonsAccessMutex.ReleaseMutex();
            GPIOButtonsAccessMutex.Dispose();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Нажата кнопка Стоп
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void StopButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                try
                {
                    switch (CurrentState)
                    {
                    case States.ReadyToDispenseWater:
                    {
                        WaterValvePin.Write(GpioPinValue.High);
                        PumpPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.High);
                        StartLEDPin.Write(GpioPinValue.Low);
                        ReadyToStartPage.ChangeWaterValveStatus(false);
                        AddItemToLogBox("Кнопка \"Стоп\" нажата в контексте продажи, кран закрыт, насос выключен");
                        break;
                    }

                    case States.ServiceMode:
                    {
                        WaterValvePin.Write(GpioPinValue.High);
                        PumpPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.High);
                        StartLEDPin.Write(GpioPinValue.Low);
                        ReadyToStartPage.ChangeWaterValveStatus(false);
                        AddItemToLogBox("Кнопка \"Стоп\" нажата в контексте служебного режима, кран закрыт, насос выключен");
                        break;
                    }

                    default:
                    {
                        AddItemToLogBox("Кнопка \"Стоп\" нажата вне контекста продажи или служебного режима, действий не требуется");
                        break;
                    }
                    }
                }
                catch
                {
                }
                finally
                {
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Нажата кнопка Сдача
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void EndButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                try
                {
                    switch (CurrentState)
                    {
                    case States.ReadyToDispenseWater:
                    {
                        CurrentState = States.DispenseChange;
                        MDB.DisableCashDevices();
                        WaterValvePin.Write(GpioPinValue.High);
                        PumpPin.Write(GpioPinValue.High);
                        StartLEDPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.High);
                        EndLEDPin.Write(GpioPinValue.High);
                        ReadyToStartPage.ChangeWaterValveStatus(false);
                        AddItemToLogBox("Сеанс продажи закончен по инициативе покупателя (нажата кнопка \"Конец\"), остаток " + UserDeposit.ToString("N2") + ", выдаем сдачу в размере " + Math.Round(UserDeposit, MidpointRounding.AwayFromZero).ToString("N2"));
                        AddItemToLogBox("Выдача сдачи");
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                var frame2 = Window.Current.Content as Frame;
                                frame2.Navigate(typeof(ChangePage));
                            });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        while (ChangePage.ChangePageInstance == null)
                        {
                            Task.Delay(100).Wait();
                        }
                        break;
                    }

                    case States.ServiceMode:
                    {
                        WaterValvePin.Write(GpioPinValue.High);
                        PumpPin.Write(GpioPinValue.High);
                        StartLEDPin.Write(GpioPinValue.High);
                        StopLEDPin.Write(GpioPinValue.High);
                        EndLEDPin.Write(GpioPinValue.High);
                        ReadyToStartPage.ChangeWaterValveStatus(false);
                        string oosfilename = ApplicationData.Current.LocalFolder.Path + "\\" + GlobalVars.HardWareID + ".031";
                        if (File.Exists(oosfilename))
                        {
                            CurrentState = States.OutOfService;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                            CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                                {
                                    var frame = Window.Current.Content as Frame;
                                    frame.Navigate(typeof(OutOfServicePage));
                                });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                            AddItemToLogBox("Временно не обслуживает");
                            return;
                        }
                        CurrentState = States.ReadyToServe;
                        MDB.EnableCashDevices();
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                            {
                                var frame = Window.Current.Content as Frame;
                                frame.Navigate(typeof(MainPage));
                            });
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                        while (MainPage.MainPageInstance == null)
                        {
                            Task.Delay(100).Wait();
                        }
                        AddItemToLogBox("Выход из служебного режима по инициативе оператора (нажата кнопка \"Конец\")");
                        break;
                    }

                    default:
                    {
                        AddItemToLogBox("Кнопка \"Конец\" нажата вне контекста продажи или служебного режима, действие не требуется.");
                        break;
                    }
                    }
                }
                catch
                {
                }
                finally
                {
                }
            }
        }
Ejemplo n.º 4
0
 public ReadyToStartPage()
 {
     InitializeComponent();
     NavigationCacheMode      = NavigationCacheMode.Required;
     ReadyToStartPageInstance = this;
 }