private static void FacadeWashMachineTest() { IWashMachine washMachine = new WashMachine(new Heater(), new Engine(), new Pump()); washMachine.SetTemperature(30); washMachine.Start(); }
private static void WashMachineTest() { // Wybieram program (steruje czasem oraz cyklem) // Ustawiam temperaturę // Ustawiam prędkość wirowania byte temperature = 40; int rotationSpeed = 1200; WashMachine washMachine = new WashMachine(new Heater(), new Engine(), new Pump()); bool quick = false; if (quick) { // Włączenie blokady washMachine.Locked = true; Console.WriteLine("Włączenie blokady"); // pobiera wodę washMachine.Pump.Direction = Direction.In; washMachine.Pump.Start(); Thread.Sleep(TimeSpan.FromSeconds(1)); washMachine.Pump.Stop(); // podgrzewa wodę int maxTemp = 30; if (temperature > maxTemp) { Console.WriteLine($"Błąd - nastawiona temperaturę większą od {maxTemp} st. C"); return; } washMachine.Heater.Temperature = temperature; washMachine.Heater.On(); // obraca bęben washMachine.Engine.RotationSpeed = 200; washMachine.Engine.RotateRight(); Thread.Sleep(TimeSpan.FromSeconds(1)); washMachine.Engine.RotateLeft(); Thread.Sleep(TimeSpan.FromSeconds(1)); // zakończenie cyklu prania washMachine.Engine.Stop(); washMachine.Engine.RotationSpeed = 0; washMachine.Heater.Off(); // wypompowanie wody washMachine.Pump.Direction = Direction.Out; washMachine.Pump.Start(); washMachine.Pump.Direction = Direction.In; washMachine.Pump.Start(); // Zwolnienie blokady washMachine.Locked = false; Console.WriteLine("Zwolnienie blokady"); } else { // Włączenie blokady washMachine.Locked = true; Console.WriteLine("Włączenie blokady"); // pobiera wodę washMachine.Pump.Direction = Direction.In; washMachine.Pump.Start(); Thread.Sleep(TimeSpan.FromSeconds(10)); washMachine.Pump.Stop(); // podgrzewa wodę washMachine.Heater.Temperature = temperature; washMachine.Heater.On(); // obraca bęben washMachine.Engine.RotationSpeed = 100; washMachine.Engine.RotateRight(); Thread.Sleep(TimeSpan.FromSeconds(5)); washMachine.Engine.RotateLeft(); Thread.Sleep(TimeSpan.FromSeconds(5)); // zakończenie cyklu prania washMachine.Engine.Stop(); washMachine.Engine.RotationSpeed = 0; washMachine.Heater.Off(); // wypompowanie wody washMachine.Pump.Direction = Direction.Out; washMachine.Pump.Start(); washMachine.Pump.Direction = Direction.In; washMachine.Pump.Start(); // wirowanie washMachine.Engine.RotationSpeed = rotationSpeed; washMachine.Engine.RotateRight(); Thread.Sleep(TimeSpan.FromSeconds(5)); // płukanie washMachine.Pump.Direction = Direction.In; washMachine.Pump.Start(); Thread.Sleep(TimeSpan.FromSeconds(10)); washMachine.Pump.Stop(); washMachine.Pump.Direction = Direction.Out; washMachine.Pump.Start(); // Zwolnienie blokady washMachine.Locked = false; Console.WriteLine("Zwolnienie blokady"); } }