/// <summary> /// Usually when the signal (RPi) battery is in a critical state. Shuts down the unit in the event of a critical /// system failure and sets the robot state. /// </summary> public static void EmergencyShutdown(TimeSpan delay) { NetworkUtils.LogNetwork(string.Format("CRITICAL SYSTEM MESSAGE: The device is shutting down in {0} seconds, use" + " ShutdownManager.CancelShutdown() to cancel", delay.TotalSeconds), MessageType.Warning); //completly shut down the robot ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, delay); }
private async void NavigateToExit() { ViewModelLocator.ResetViewModels(); await startButtons.Dispose(); ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); }
private void UpdateTime(object sender, object e) { _Time = _Time - 2; state.Text += "."; shbo.SetBrightnessLevel(_Time / 100, DisplayBrightnessOverrideOptions.None); if (_Time > MaxTime) { return; } try { this.timerProgress.Stop(); timerProgress.Tick -= UpdateTime; shbo.SetBrightnessLevel(0, DisplayBrightnessOverrideOptions.None); //shbo.StopOverride(); if (_shutdown) { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5)); } if (_reboot) { ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0.5)); } } catch (Exception ex) { Debug.WriteLine("UpdateTime Error :" + ex.Message); } }
private void ShutdownHelper(ShutdownKind kind) { new System.Threading.Tasks.Task(() => { ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0)); }).Start(); }
private void btn_finishing2_Click(object sender, RoutedEventArgs e) { new DBConn_SaleSearch().Finish(); //영수증 출력 후 시스템 종료 /*시스템 즉시 종료*/ ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.Zero); }
private async Task <MethodResponse> RestartAsync(MethodRequest methodRequest, object userContext) { this.logging.LogEvent("Reboot initiated"); ShutdownManager.BeginShutdown(ShutdownKind.Restart, this.deviceRebootDelayPeriod); return(new MethodResponse(200)); }
private void ButtonpinValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args) { // Just shutdown on one edge if (args.Edge == GpioPinEdge.RisingEdge) { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5)); } }
private async void Btn_system_beenden_Click(object sender, RoutedEventArgs e) { await User_Check("Soll Windows wirklich heruntergefahren werden?", "Windows herunterfahren"); if (result) { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); } }
private void SetFinishing() { /*마감 처리에 필요한 기능 중지*/ new DBConn_MemberTime().UpdateMemberTime(POS_main.managerName); new DBConn_SaleSearch().Finish(); /*시스템 종료*/ ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(2)); }
private async void Btn_system_neustart_Click(object sender, RoutedEventArgs e) { await User_Check("Soll Windows wirklich neu gestartet werden?", "Windows neu starten"); if (result) { ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0)); } }
#pragma warning disable 1998 private async Task <MethodResponse> RestartAsync(MethodRequest methodRequest, object userContext) { if (bme280InputPollingTimer != null) { bme280InputPollingTimer.Change(Timeout.Infinite, Timeout.Infinite); } ShutdownManager.BeginShutdown(ShutdownKind.Restart, deviceRestartPeriod); return(new MethodResponse(200)); }
private void PowerButton_Click(object sender, RoutedEventArgs e) { try { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); } catch (Exception ex) { new MessageDialog("Are you running on an IoT core device? Shutdown only works there.\n" + ex.Message, "Could not shhutdown").ShowAsync().AsTask().Wait(); } }
// Browser sends something back void OnDataReceived(WebSocket socket, string frame) { switch (frame) { case "Client Connected": break; case "shutdown": ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, new TimeSpan(0)); break; } }
private void RestartSystem_Click(object sender, RoutedEventArgs e) { try { ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(0)); } catch (Exception ex) { Info_field.Visibility = Visibility.Visible; Info_field.Text = ex.Message; } }
protected override void OnKeyDown(KeyRoutedEventArgs e) { base.OnKeyDown(e); if (e.Key == VirtualKey.Home) { exitCounter++; if (exitCounter >= 3) { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); } } if (e.Key == VirtualKey.Up) { isOnRoundTime = true; } if (e.Key == VirtualKey.Down) { isOnRoundTime = false; } if (e.Key == VirtualKey.Enter) { StartOrPauseTimer(); } if (btnDecreaseTime.IsEnabled && e.Key == VirtualKey.Left && isOnRoundTime) { DecreaseRoundTime(); } if (btnDecreaseRestTime.IsEnabled && e.Key == VirtualKey.Left && !isOnRoundTime) { DecreaseRestTime(); } if (btnIncreaseTime.IsEnabled && e.Key == VirtualKey.Right && isOnRoundTime) { IncreaseRoundTime(); } if (btnIncreaseRestTime.IsEnabled && e.Key == VirtualKey.Right && !isOnRoundTime) { IncreaseRestTime(); } if (e.Key == VirtualKey.Application) { ResetTimer(); } }
/// <summary> /// IComputerManager implementation /// </summary> public void ShutdownComputer() { try { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(1.0)); Speak("shutting down"); } catch { Speak("Cannot shut down this computer"); } }
public async void ShowPowerDialog(ShutdownKind kind) { var dialog = (kind == ShutdownKind.Restart ? RestartDialog : ShutdownDialog); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary && IsIoTDeviceFamily) { await CommService.DisconnectAsync(); ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0)); } }
private void ShutdownHelper(ShutdownKind kind) { try { ShutdownManager.BeginShutdown(kind, TimeSpan.FromSeconds(0.5)); } catch (Exception e) { // Catching the exception ensures this doesn't crash the app on non-IOT devices Debug.WriteLine("Couldn't begin shutdown: " + e.Message); } }
private void RebootTimer_Tick(object sender, object e) { // Save the programs Task <bool> t = SprinklerManagement.SavePrograms(); while (!t.IsCompleted) { ; } //reboot the device ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0, 0, 5)); }
public void RebootComputer(object target, RoutedEventArgs args) { Debug.WriteLine("Reboot"); this.gpio = GpioController.GetDefault(); if (gpio == null) { Debug.WriteLine("No ShutdownManager available."); } else { ShutdownManager.BeginShutdown(ShutdownKind.Restart, new TimeSpan(0)); } }
#pragma warning disable 1998 private async Task <MethodResponse> DeviceRebootAsync(MethodRequest methodRequest, object userContext) { this.logging.LogEvent("Reboot initiated"); // Stop the image capture timer before reboot if (this.imageUpdatetimer != null) { this.imageUpdatetimer.Change(Timeout.Infinite, Timeout.Infinite); } ShutdownManager.BeginShutdown(ShutdownKind.Restart, this.deviceRebootDelayPeriod); return(new MethodResponse(200)); }
private void Btn_SaveIP_Click(object sender, RoutedEventArgs e) { FindAdapterName(); ChangePORT(); ChangeIPAddress(TxtBx_IPChoix.Text); if (ChangementEffectue == true) { ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.FromSeconds(5)); MsgALERTAsync("Le Raspberry va redémarrer dans 5 secondes."); } else { MsgALERTAsync("Aucunes modifications n'ont été éffectuées.\nPour Quitter, cliquez sur la croix en haut a droite."); } }
private void Shutdown() { try { // Shutdowns the device immediately. if (ApiInformation.IsTypePresent("Windows.System.ShutdownManager")) { SoundPlayer.Instance.Play(Sounds.Shutdown); ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(3)); } } catch { } }
// Button Listener private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.FallingEdge) { // This test is here because the user *might* have another HAT plugged in or another circuit that produces a // falling-edge signal on another GPIO pin. if (sender != clockPin) { return; } // We can get the state of a pin with GPIO.input even when it is currently configured as an output // Python: self.sqwave = not GPIO.input(PULSE_PIN) GpioPinValue initialValue = (pulsePin.Read() == GpioPinValue.High ? GpioPinValue.Low : GpioPinValue.High); // Set pulse pin low before changing it to input to look for shutdown signal // Python: GPIO.output(PULSE_PIN, False) pulsePin.Write(GpioPinValue.Low); // Python: GPIO.setup(PULSE_PIN, GPIO.IN, pull_up_down = GPIO.PUD_UP) pulsePin.SetDriveMode(clockPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp) ? GpioPinDriveMode.InputPullUp : GpioPinDriveMode.Input); if (pulsePin.Read() == GpioPinValue.Low) { counter = counter++; Debug.WriteLine("Lost power, starting shutdown"); Task.Delay(new TimeSpan(0, 0, 2)); Debug.WriteLine("Shutting down..."); // Shutdown the device immediately ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); } else { counter = 0; } pulsePin.SetDriveMode(GpioPinDriveMode.Output); pulsePin.Write(initialValue); } }
private async void shutdownPiCommandButton_Click(object sender, RoutedEventArgs e) { ContentDialog shutdownConfirmDialog = new ContentDialog { Title = "Shutdown?", Content = "Do you want to shutdown this RaspberryPi device? (The slider will continue to operate.)", PrimaryButtonText = "Shutdown", CloseButtonText = "Cancel" }; ContentDialogResult result = await shutdownConfirmDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0)); } }
private async void EteindreBTN_Click(object sender, RoutedEventArgs e) { ContentDialog confirmationExtinction = new ContentDialog() { Title = "Eteindre ?", PrimaryButtonText = "OK", SecondaryButtonText = "Annuler" }; if (await confirmationExtinction.ShowAsync() == ContentDialogResult.Primary) { await _nadHat.Eteindre(false); #if DEBUG App.Current.Exit(); #else ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, new TimeSpan(0)); #endif } }
private async void ShutDown_Click(object sender, RoutedEventArgs e) { MessageDialog dialog = new MessageDialog("Are you sure you want to Shutdown?"); dialog.Title = "Shutting Down?"; dialog.Commands.Add(new UICommand("Yes", null)); dialog.Commands.Add(new UICommand("No", null)); dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; var cmd = await dialog.ShowAsync(); if (cmd.Label == "Yes") { // Shutdowns the device immediately: ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(5)); } }
/*Main Page*/ private async void MainPage_Loaded(object sender, RoutedEventArgs e) { //Select the first step in the Recipe editor StepSelector.SelectedIndex = 0; //Get current oven status var status = await Oven.GetStatus(); Status.Text = status.ToString(); //Restart if the oven tells us to if (status == OvenStatus.NeedRestart) { ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.Zero); return; } //Start sample timer SamplePoll.Start(); //Look for recipe files and populate recipe list var files = (await LocalFolder.GetFilesAsync()) .Where(x => x.Name.EndsWith(RecipeFilenameExtension)); if (files.Any()) { foreach (var filename in files .Select(x => x.Name.Remove(x.Name.Length - RecipeFilenameExtension.Length))) { RecipeFiles.Add(filename); } } //Read PID coefficients from stored settings if (Settings.ContainsKey(nameof(PID)) && Settings[nameof(PID)] is string pidString) { var pid = PID.FromString(pidString); PInput.Value = pid.Proportional; IInput.Value = pid.Integral; DInput.Value = pid.Derivative; SendPID_Click(this, new RoutedEventArgs()); } }
private async Task <MethodResponse> RestartAsync(MethodRequest methodRequest, object userContext) { LoggingFields restartLoggingInfo = new LoggingFields(); #if CLOUD_DEVICE_SEND restartLoggingInfo.AddInt32("Send message queue count", sendMessageQueue.Count); #endif restartLoggingInfo.AddTimeSpan("Device restart period", DeviceRestartPeriod); // Disconnect the transmit and receive callbacks, once messages Send & Push need to consider what todo with queued outbound messages rfm9XDevice.OnReceive -= Rfm9XDevice_OnReceive; rfm9XDevice.OnTransmit -= Rfm9XDevice_OnTransmit; this.logging.LogEvent("Restart initiated", restartLoggingInfo, LoggingLevel.Information); ShutdownManager.BeginShutdown(ShutdownKind.Restart, DeviceRestartPeriod); return(new MethodResponse(200)); }
private async void PowerConfiguration() { var res = await CustomDialog.AskPowerOff(); if (res == ContentDialogResult.Primary) { //Debug.WriteLine("Shutdown"); ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.Zero); } else if (res == ContentDialogResult.Secondary) { //Debug.WriteLine("Reboot"); ShutdownManager.BeginShutdown(ShutdownKind.Restart, TimeSpan.Zero); } else { //Debug.WriteLine("Cancel"); } }