diff --git a/Microwave.App/Program.cs b/Microwave.App/Program.cs index d52457a9227ea4e641aa316ac46ef5f4c638409c..8a871a292f306f399da1a5832544d6c389649bbd 100644 --- a/Microwave.App/Program.cs +++ b/Microwave.App/Program.cs @@ -1,6 +1,8 @@ using System; +using System.Threading; using Microwave.Classes.Boundary; using Microwave.Classes.Controllers; +using Timer = Microwave.Classes.Boundary.Timer; namespace Microwave.App { @@ -40,31 +42,30 @@ namespace Microwave.App var powerButtonPresses = 20; + for (int i = 0; i < powerButtonPresses; i++) + { + powerButton.Press(); + } defrostButton.Press(); + timeButton.Press(); + startCancelButton.Press(); - for (int i = 0; i < powerButtonPresses; i++) - { - powerButton.Press(); - } // The simple sequence should now run - timeButton.Press(); - - startCancelButton.Press(); - - // The simple sequence should now run + System.Console.WriteLine("press 's' to stop program or 't' to extend the cooking time"); - System.Console.WriteLine("When you press enter, the program will stop"); - // Wait for input + char key = '0'; + while (key != 's') + { + key = System.Console.ReadKey().KeyChar; - //string input = System.Console.ReadLine(); - //if(input == "t") - // timeButton.Press(); + if(key == 't') + timeButton.Press(); + } - System.Console.ReadLine(); } diff --git a/Microwave.Classes/Controllers/CookController.cs b/Microwave.Classes/Controllers/CookController.cs index e06bc80233805445f7dd3b50bf5a0400576b5374..0ff7416489ebd848d3b94049254ab4da69a0752f 100644 --- a/Microwave.Classes/Controllers/CookController.cs +++ b/Microwave.Classes/Controllers/CookController.cs @@ -1,5 +1,6 @@ using System; using System.Threading; +using System.Threading.Tasks; using Microwave.Classes.Interfaces; namespace Microwave.Classes.Controllers @@ -85,17 +86,19 @@ namespace Microwave.Classes.Controllers } } - public void Defrost(int power) + public async void Defrost(int power) { Console.WriteLine("Defrosting is on"); while (isCooking) { - Thread.Sleep(10000); + await Task.Delay(10000); + myPowerTube.TurnOff(); - Thread.Sleep(10000); - myPowerTube.TurnOn(power); + await Task.Delay(10000); + + myPowerTube.TurnOn(power); } }