/// <summary> /// The set switch. /// </summary> /// <param name="maker"> /// The maker. /// </param> /// <param name="state"> /// The state. /// </param> public static void SetSwitch(BiscuitMakerObject maker, SwitchState state) { var newSwitch = Switch.Create(state); maker.Components.Remove(maker.FirstSwitch); maker.Components.Add(newSwitch); }
/// <summary> /// The set state. /// </summary> /// <param name="maker"> /// The maker. /// </param> /// <param name="currentTemperature"> /// The current temperature. /// </param> /// <param name="state"> /// The state. /// </param> public static void SetState(BiscuitMakerObject maker, int currentTemperature, OvenState state) { var isWorkingTemperature = currentTemperature <= maker.Settings.OvenMaxTemp && currentTemperature >= maker.Settings.OvenMinTemp; var newOven = Oven.Create(currentTemperature, state, isWorkingTemperature); maker.Components.Remove(maker.FirstOven); maker.Components.Add(newOven); }
/// <summary> /// The create. /// </summary> /// <param name="settings"> /// The settings. /// </param> /// <returns> /// The <see cref="BiscuitMakerObject"/>. /// </returns> public static BiscuitMakerObject Create(BiscuitMakerSettings settings = null) { var settingsAreValid = BiscuitMakerSettingsValidator.ValidateSettings(settings, false); if (!settingsAreValid) { return(null); } var components = new List <IBiscuitComponent>(); var switchComponent = Switch.Create(); components.Add(switchComponent); var switcher = new Switcher(); components.Add(switcher); if (settings != null) { var conveyor = Conveyor.Create(count: settings.ConveyorSize); components.Add(conveyor); } if (settings != null) { var oven = Oven.Create(settings.RoomTemperature); components.Add(oven); } var bucket = BiscuitBucket.Create(); components.Add(bucket); var motor = new Motor(); components.Add(motor); var timeRunner = new TimeRunner(); components.Add(timeRunner); var biscuitMaker = BiscuitMakerObject.Create(components, settings); biscuitMaker.FirstSwitcher.RaiseSwitchOn += OvenManager.HandleSwitchOn; biscuitMaker.FirstTimeRunner.RaiseClockTick += OvenManager.HandleClockTick; biscuitMaker.FirstTimeRunner.RaiseClockTick += biscuitMaker.FirstMotor.HandleClockTick; biscuitMaker.FirstMotor.RaisePulse += ConveyorManager.HandleMotorPulse; return(biscuitMaker); }
public void SetUp() { this.Maker = BiscuitMakerFactory.Create(settings); }
/// <summary> /// The tick. /// </summary> /// <param name="maker"> /// The maker. /// </param> public static void Tick(BiscuitMakerObject maker) { maker.FirstTimeRunner.Tick(maker); }
/// <summary> /// The pause. /// </summary> /// <param name="maker"> /// The maker. /// </param> public static void Pause(BiscuitMakerObject maker) { maker.FirstSwitcher.Pause(maker); }
/// <summary> /// The turn off. /// </summary> /// <param name="maker"> /// The maker. /// </param> public static void TurnOff(BiscuitMakerObject maker) { maker.FirstSwitcher.TurnOff(maker); }
/// <summary> /// The pulse. /// </summary> /// <param name="maker"> /// The maker. /// </param> public void Pulse(BiscuitMakerObject maker) { this.RaisePulse?.Invoke(this, new OnMotorPulseEventArgs { Maker = maker }); }
/// <summary> /// The switch on. /// </summary> /// <param name="maker"> /// The maker. /// </param> public void SwitchOn(BiscuitMakerObject maker) { this.RaiseSwitchOn?.Invoke(this, new OnSwitchOnEventArgs { Maker = maker }); }
/// <summary> /// The pause. /// </summary> /// <param name="maker"> /// The maker. /// </param> public void Pause(BiscuitMakerObject maker) { Switcher.SetSwitch(maker, SwitchState.Pause); this.SwitchPause(maker); }
/// <summary> /// The turn off. /// </summary> /// <param name="maker"> /// The maker. /// </param> public void TurnOff(BiscuitMakerObject maker) { Switcher.SetSwitch(maker, SwitchState.Off); this.SwitchOff(maker); }
/// <summary> /// Initializes a new instance of the <see cref="BiscuitMakerDisplay"/> class. /// </summary> /// <param name="maker"> /// The maker. /// </param> public BiscuitMakerDisplay(BiscuitMakerObject maker) { this.Maker = maker; }
/// <summary> /// The tick. /// </summary> /// <param name="maker"> /// The maker. /// </param> public void Tick(BiscuitMakerObject maker) { this.RaiseClockTick?.Invoke(this, new OnClockTickEventArgs { Maker = maker }); }
public BiscuitMakerConsoleDisplay(BiscuitMakerObject maker) : base(maker) { this.Margin = " "; }