using FSM.Machines; using FSM.Recipes; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FSM.States { class IdleState : IEquipmentState { private Recipe _currentRecipe; public void Enter() { Console.WriteLine("Entering IdleState"); } public void Exit() { Console.WriteLine("Exiting IdleState"); } public void SetRecipe(Recipe recipe) { _currentRecipe = recipe; Console.WriteLine(string.Format("Recipe {0} set in IdleState", _currentRecipe.Name)); } public bool HandleEvent(EquipmentEvent equipmentEvent, Machines.EquipmentStateMachine machine) { switch (equipmentEvent) { case EquipmentEvent.Start: if (_currentRecipe != null) { machine.SetState(new RunningState(_currentRecipe)); return true; } Console.WriteLine("No recipe set. Unable to start."); return false; case EquipmentEvent.EmergencyStop: machine.SetState(new EmergencyStoppedState()); return true; default: return false; } } } }