Exemple #1
0
        /*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());
            }
        }