You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|