public AddState ( IStateMachineState state ) : void | ||
state | IStateMachineState | |
Результат | void |
public static StateMachineState AddOnState(this StateMachine stateMachine) { if (stateMachine == null) { throw new ArgumentNullException(nameof(stateMachine)); } return(stateMachine.AddState(BinaryStateId.On)); }
public static StateMachineState AddOffState(this StateMachine stateMachine) { if (stateMachine == null) { throw new ArgumentNullException(nameof(stateMachine)); } return(stateMachine.AddState(StateMachineStateExtensions.OffStateId)); }
public static StateMachineState AddState(this StateMachine stateMachine, StatefulComponentState id) { if (stateMachine == null) { throw new ArgumentNullException(nameof(stateMachine)); } if (id == null) { throw new ArgumentNullException(nameof(id)); } var state = new StateMachineState(id); stateMachine.AddState(state); return(state); }
private void SetupStateMachine(StateMachine stateMachine, IArea garden) { stateMachine.AddOffState() .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("Te")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("G")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("W")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("D")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("Ti")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On); stateMachine.AddState(new NamedComponentState("G+W")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("Te+G+W")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off); stateMachine.AddState(new NamedComponentState("Te+G+W+D+Ti")) .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On) .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On); }