Skip to content
Snippets Groups Projects
Commit 8f620930 authored by Linda Nguyen's avatar Linda Nguyen
Browse files

added functionality to main program to be able to add time while cooking, as...

added functionality to main program to be able to add time while cooking, as well as changed defrost function to be able to run parallel
parent 53ef62b6
Branches ChangeTimeWhileCooking
No related tags found
1 merge request!17final merge request related to addtime feature
Pipeline #194520 passed
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();
}
......
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);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment