/// <summary> /// выдаем сдачу пока депозит не станет равен 0 /// </summary> private void DispenseChange() { ChangeModeSemaphore.Wait(); if (StartPage.CurrentState != StartPage.States.DispenseChange) { ChangeModeSemaphore.Release(); return; } #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, () => { dispenselabel.Text = Math.Round(StartPage.UserDeposit, 0, MidpointRounding.AwayFromZero).ToString().PadLeft(3, '0'); }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed if (StartPage.CurrentDeviceSettings.UseKKT && Math.Round(StartPage.CurrentSaleSession.Quantity, 3) > 0) { try { StartPage.CurrentSaleSession.ReceiptNumber = StartPage.SystemState.KKTReceiptNextNumber; StartPage.CurrentSaleSession.StageNumber = Convert.ToInt16(StartPage.SystemState.KKTStageNumber); StartPage.CurrentSaleSession.TaxSystemInUse = StartPage.CurrentDeviceSettings.TaxSystem; if (Math.Round(StartPage.UserDeposit, 2, MidpointRounding.AwayFromZero) == 0) { CashDesk.PrintReceipt(GlobalVars.ReceiptLinesToPrint, (((int)(Math.Round(StartPage.CurrentSaleSession.UserCash, 2) * 100)) * 1.00 / StartPage.CurrentSaleSession.PRICE_PER_ITEM_MDE), StartPage.CurrentSaleSession.PRICE_PER_ITEM_MDE, (int)(Math.Round(StartPage.CurrentSaleSession.UserCash, 2) * 100)); } else { CashDesk.PrintReceipt(GlobalVars.ReceiptLinesToPrint, Math.Round(StartPage.CurrentSaleSession.Quantity, 3), StartPage.CurrentSaleSession.PRICE_PER_ITEM_MDE, (int)(Math.Round(StartPage.CurrentSaleSession.UserCash, 2) * 100)); } } catch { } } Task.Delay(15000).Wait(); try { CashDesk.GetCurrentStageParameters(); StartPage.CurrentSaleSession.ActualChangeDispensed = (int)Math.Round(StartPage.UserDeposit, 0, MidpointRounding.AwayFromZero); StartPage.CurrentSaleSession.ChangeActualDiff = StartPage.CurrentSaleSession.ActualChangeDispensed - StartPage.UserDeposit; StartPage.CurrentSaleSession.CompleteSession(); ServiceTasks.UpdateWaterCounter(StartPage.CurrentSaleSession.Quantity); StartPage.UserDeposit = Math.Round(StartPage.UserDeposit, 0, MidpointRounding.AwayFromZero); while ((int)StartPage.UserDeposit > 0) { while (MDB.DispenseInProgress || MDB.CheckDispenseResult) { Task.Delay(1000).Wait(); } int _change = (int)StartPage.UserDeposit; if (_change > 127)//не более 127 рублей в одной порции сдачи, ограничение монетоприемника { _change = 127; } MDB.Dispensetimeout = DateTime.Now.AddSeconds(10); MDB.PayoutCoins(_change);//выдаем сдачу монетами StartPage.UserDeposit -= _change; Task.Delay(2000).Wait(); } string oosfilename = ApplicationData.Current.LocalFolder.Path + "\\" + GlobalVars.HardWareID + ".031"; if (File.Exists(oosfilename)) { StartPage.CurrentState = StartPage.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 return; } StartPage.CurrentState = StartPage.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 } catch { } ChangeModeSemaphore.Release(); }
/// <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 { } } }