/*Operations*/ private async void SamplePoll_Tick(object sender, object e) { //Periodically poll for current data //Get current sample Sample sample = await Oven.GetCurrentSample(); UpdateSampleUI(sample); //Add sample to graph if (sample != null) { SampleData.Add(sample); } //Get the oven's current status code var status = await Oven.GetStatus(); if (status == OvenStatus.NotConnected && Oven.ErrorMessage != null) { Status.Text = Oven.ErrorMessage; } else { Status.Text = status.ToString(); } }
/*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()); } }