/// <summary> /// информация о состоянии смены /// </summary> /// <param name="StageStateString"></param> private static void CashDesk_StageStateReceived(StageProperties StageState) { try { //SystemState.KKTStageOpened = (StageState.CurrentStageState == StageProperties.StageState.Opened); StartPage.SystemState.KKTStageOver24h = (StageState.CurrentStageState == StageProperties.StageState.Over24h); StartPage.SystemState.LastStageClosedDateTime = Convert.ToInt64(StageState.StageClosedDateTime.ToString("yyyyMMddHHmmss")); StartPage.SystemState.LastStageClosedDateTimeStr = StageState.StageClosedDateTime.ToString("dd.MM.yyyy HH:mm:ss"); if (StartPage.CurrentState != StartPage.States.Init && StartPage.CurrentState != StartPage.States.OutOfService && StartPage.CurrentState != StartPage.States.ServiceMode && StartPage.SystemState.KKTStageOver24h) { StartPage.CurrentState = StartPage.States.OutOfService; MDB.DisableCashDevices(); #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 StartPage.AddItemToLogBox("Длительность смены превысила 24ч, устройство переведено в режим \"Не обслуживает\""); } } catch { } }
/// <summary> /// Критическая ошибка устройств приема наличных /// </summary> /// <param name="ErrorMessage"></param> private static void CashDevices_MDBError(string ErrorMessage) { if ((StartPage.CurrentState == StartPage.States.ReadyToServe) || (StartPage.CurrentState == StartPage.States.ReadyToDispenseWater) || (StartPage.CurrentState == StartPage.States.DispenseChange)) { StartPage.CurrentState = StartPage.States.OutOfService; MDB.MDBInitStep = 6; MDB.DisableCashDevices(); #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 StartPage.AddItemToLogBox("Устройства приема наличных принудительно отключены из-за ошибки."); } }
/// <summary> /// Прибавляет 50мл к счетчику отгруженной водички /// </summary> /// <returns></returns> public static void WaterCounterTicked() { if (StartPage.CurrentState == StartPage.States.ReadyToDispenseWater || StartPage.CurrentState == StartPage.States.ServiceMode) { watercountertickerSemaphore.Wait(); if (!(StartPage.CurrentState == StartPage.States.ReadyToDispenseWater || StartPage.CurrentState == StartPage.States.ServiceMode)) { watercountertickerSemaphore.Release(); return; } StartPage.WaterFlowPulseCounter++; if (StartPage.WaterFlowPulseCounter >= 17)//50ml dispensed { StartPage.WaterFlowPulseCounter = 0; if (StartPage.CurrentState == StartPage.States.ReadyToDispenseWater) { StartPage.UserDeposit -= Math.Round(StartPage.CurrentSaleSession.PRICE_PER_ITEM_MDE * 0.0005, 2); StartPage.CurrentSaleSession.Quantity += 0.05; if (Math.Round(StartPage.CurrentSaleSession.UserCash, 2) <= Math.Round(StartPage.CurrentSaleSession.Quantity * StartPage.CurrentSaleSession.PRICE_PER_ITEM_MDE * 0.01, 2)) { StartPage.CurrentState = StartPage.States.DispenseChange; StartPage.WaterValvePin.Write(GpioPinValue.High); StartPage.PumpPin.Write(GpioPinValue.High); StartPage.StartLEDPin.Write(GpioPinValue.High); StartPage.StopLEDPin.Write(GpioPinValue.High); StartPage.EndLEDPin.Write(GpioPinValue.High); MDB.DisableCashDevices(); #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(ChangePage)); }); #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed } } } watercountertickerSemaphore.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 { } } }