//Populate dictionary of State Nodes and their respective State Machine protected virtual void PopulateStateNodeDict(StateMachineGraph stateMachine) { foreach (var stateNode in stateMachine.stateNodes) { stateNodeDict.Add(stateNode, stateMachine); } }
public void Setup() { _machine = AutomatonymousStateMachine <Instance> .New(b => b .State("Running", out State Running) .State("Suspended", out State Suspended) .State("Failed", out State Failed) .Event("Initialized", out Event Initialized) .Event("Suspend", out Event Suspend) .Event("Resume", out Event Resume) .Event("Finished", out Event Finished) .Event <RestartData>("Restart", out Event <RestartData> Restart) .During(b.Initial) .When(Initialized, (binder) => binder .TransitionTo(Running) .Catch <Exception>(h => h.TransitionTo(Failed)) ) .During(Running) .When(Finished, (binder) => binder.TransitionTo(b.Final)) .When(Suspend, (binder) => binder.TransitionTo(Suspended)) .Ignore(Resume) .During(Suspended) .When(Resume, b => b.TransitionTo(Running)) .During(Failed) .When(Restart, context => context.Data.Name != null, b => b.TransitionTo(Running)) ); _graph = _machine.GetGraph(); }
public ServiceBase() { _stateMachine = new StateMachineGraph<ServiceStateEnum, ServiceTriggersEnum>(ServiceStateEnum.Uninitialized); _stateMachine.AllowTransition(ServiceStateEnum.Uninitialized, ServiceStateEnum.Initialized, ServiceTriggersEnum.Initialize); _stateMachine.AllowTransition(ServiceStateEnum.Initialized, ServiceStateEnum.Started, ServiceTriggersEnum.Start); _stateMachine.AllowTransition(ServiceStateEnum.Started, ServiceStateEnum.Stopped, ServiceTriggersEnum.Stop); _stateMachine.AllowTransition(ServiceStateEnum.Stopped, ServiceStateEnum.Started, ServiceTriggersEnum.Start); }
public ServiceBase() { _stateMachine = new StateMachineGraph <ServiceStateEnum, ServiceTriggersEnum>(ServiceStateEnum.Uninitialized); _stateMachine.AllowTransition(ServiceStateEnum.Uninitialized, ServiceStateEnum.Initialized, ServiceTriggersEnum.Initialize); _stateMachine.AllowTransition(ServiceStateEnum.Initialized, ServiceStateEnum.Started, ServiceTriggersEnum.Start); _stateMachine.AllowTransition(ServiceStateEnum.Started, ServiceStateEnum.Stopped, ServiceTriggersEnum.Stop); _stateMachine.AllowTransition(ServiceStateEnum.Stopped, ServiceStateEnum.Started, ServiceTriggersEnum.Start); }
static AdjacencyGraph<Vertex, Edge<Vertex>> CreateAdjacencyGraph(StateMachineGraph data) { var graph = new AdjacencyGraph<Vertex, Edge<Vertex>>(); graph.AddVertexRange(data.Vertices); graph.AddEdgeRange(data.Edges.Select(x => new Edge<Vertex>(x.From, x.To))); return graph; }
static AdjacencyGraph <Vertex, Edge <Vertex> > CreateAdjacencyGraph(StateMachineGraph data) { var graph = new AdjacencyGraph <Vertex, Edge <Vertex> >(); graph.AddVertexRange(data.Vertices); graph.AddEdgeRange(data.Edges.Select(x => new Edge <Vertex>(x.From, x.To))); return(graph); }
public bool CompareCurrentGraph(StateMachineGraph comparingTo) { if (stateGraph == null) { return(false); } return(stateGraph.Equals(comparingTo)); }
public FluentActivityBase() : base() { //define the graph _stateMachine = new StateMachineGraph <FluentItemStatusEnum, FluentItemStateTransitionEnum>(FluentItemStatusEnum.Pending); _stateMachine.AllowTransition(FluentItemStatusEnum.Pending, FluentItemStatusEnum.Complete, FluentItemStateTransitionEnum.MarkComplete); _stateMachine.AllowTransition(FluentItemStatusEnum.Pending, FluentItemStatusEnum.Error, FluentItemStateTransitionEnum.MarkError); this.Store = EncodedInMemoryStore.New().WithIsOfUniqueId <IFluentActivity>(); this.Id = 0; this.Store.SaveItem(this); }
public void SaveGraphToFile(StateMachineGraph data, int width, int height, string filename) { Microsoft.Glee.Drawing.Graph gleeGraph = CreateGraph(data); var renderer = new GraphRenderer(gleeGraph); renderer.CalculateLayout(); var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); renderer.Render(bitmap); bitmap.Save(filename, ImageFormat.Png); }
public override void OnBodyGUI() { base.OnBodyGUI(); ConditionalRootNode node = target as ConditionalRootNode; ConditionalGraph condGraph = node.graph as ConditionalGraph; if (GUILayout.Button("Back To State Graph")) { StateMachineGraph fsmgraph = condGraph.parentNode.graph as StateMachineGraph; NodeEditorWindow.Open(fsmgraph); } }
public TaskBase(string id) { Condition.Requires(id).IsNotNullOrEmpty(); //define the graph _stateMachine = new StateMachineGraph<DecoratidTaskStatusEnum, DecoratidTaskTransitionEnum>(DecoratidTaskStatusEnum.Pending); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.InProcess, DecoratidTaskTransitionEnum.Perform); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Complete, DecoratidTaskTransitionEnum.MarkComplete); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Errored, DecoratidTaskTransitionEnum.MarkErrored); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); this.Id = id; }
public void SaveGraphToFile(StateMachineGraph data, int width, int height, string filename) { Graph gleeGraph = CreateGraph(data); var renderer = new GraphRenderer(gleeGraph); renderer.CalculateLayout(); var bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); renderer.Render(bitmap); bitmap.Save(filename, ImageFormat.Png); }
//Send requesting state machine list of active states //For transition node valid start states public virtual List <StateNode> GetActiveStates(StateMachineGraph requestingStateMachine) { List <StateNode> activeStates = new List <StateNode>(); foreach (var stateMachine in stateMachines) { foreach (var currentState in stateMachine.currentStates) { activeStates.Add(currentState); } } return(activeStates); }
public TaskBase(string id) { Condition.Requires(id).IsNotNullOrEmpty(); //define the graph _stateMachine = new StateMachineGraph <DecoratidTaskStatusEnum, DecoratidTaskTransitionEnum>(DecoratidTaskStatusEnum.Pending); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.InProcess, DecoratidTaskTransitionEnum.Perform); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Complete, DecoratidTaskTransitionEnum.MarkComplete); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Errored, DecoratidTaskTransitionEnum.MarkErrored); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); this.Id = id; }
public TaskingLogicDecoration(ILogic decorated, string taskId, ILogic cancelLogic = null) : base(decorated) { Condition.Requires(taskId).IsNotNullOrEmpty(); this.Id = taskId; //define the graph _stateMachine = new StateMachineGraph <DecoratidTaskStatusEnum, DecoratidTaskTransitionEnum>(DecoratidTaskStatusEnum.Pending); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.InProcess, DecoratidTaskTransitionEnum.Perform); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Complete, DecoratidTaskTransitionEnum.MarkComplete); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Errored, DecoratidTaskTransitionEnum.MarkErrored); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); this.CancelLogic = cancelLogic; }
public TaskingLogicDecoration(ILogic decorated, string taskId, ILogic cancelLogic = null) : base(decorated) { Condition.Requires(taskId).IsNotNullOrEmpty(); this.Id = taskId; //define the graph _stateMachine = new StateMachineGraph<DecoratidTaskStatusEnum, DecoratidTaskTransitionEnum>(DecoratidTaskStatusEnum.Pending); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.InProcess, DecoratidTaskTransitionEnum.Perform); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.Pending, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Complete, DecoratidTaskTransitionEnum.MarkComplete); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Errored, DecoratidTaskTransitionEnum.MarkErrored); _stateMachine.AllowTransition(DecoratidTaskStatusEnum.InProcess, DecoratidTaskStatusEnum.Cancelled, DecoratidTaskTransitionEnum.Cancel); this.CancelLogic = cancelLogic; }
public void Populate() { StateMachineReferences.Clear(); foreach (var propertyPath in AssetDatabaseUtils.GetAssetRelativePaths(FolderPath, true)) { StateMachineGraph assetAsStateMachine = AssetDatabase.LoadAssetAtPath(propertyPath, typeof(StateMachineGraph)) as StateMachineGraph; if (assetAsStateMachine != null) { StateMachineReference stateMachineReference = new StateMachineReference(); stateMachineReference.StateMachine = assetAsStateMachine; StateMachineReferences.Add(stateMachineReference); continue; } } }
public Graph CreateGraph(StateMachineGraph data) { var graph = new AdjacencyGraph <Vertex, Edge <Vertex> >(); graph.AddVertexRange(data.Vertices); graph.AddEdgeRange(data.Edges.Select(x => new Edge <Vertex>(x.From, x.To))); GleeGraphPopulator <Vertex, Edge <Vertex> > glee = graph.CreateGleePopulator(); glee.NodeAdded += NodeStyler; glee.EdgeAdded += EdgeStyler; glee.Compute(); Graph gleeGraph = glee.GleeGraph; return(gleeGraph); }
public Microsoft.Glee.Drawing.Graph CreateGraph(StateMachineGraph data) { var graph = new AdjacencyGraph<Vertex, Edge<Vertex>>(); graph.AddVertexRange(data.Vertices); graph.AddEdgeRange(data.Edges.Select(x => new Edge<Vertex>(x.From, x.To))); GleeGraphPopulator<Vertex, Edge<Vertex>> glee = graph.CreateGleePopulator(); glee.NodeAdded += NodeStyler; glee.EdgeAdded += EdgeStyler; glee.Compute(); Microsoft.Glee.Drawing.Graph gleeGraph = glee.GleeGraph; return gleeGraph; }
protected override void InjectNodeDependencies(StateMachineGraph stateMachine) { base.InjectNodeDependencies(stateMachine); foreach (var stateNode in stateMachine.stateNodes) { if (stateNode is PlayerStateNode playerState) { playerState.SetDependencies(playerController); } //Init playerStateNodes within subStateProcessor if (stateNode is SubStateProcessorNode nodeAsSubState) { foreach (var subState in nodeAsSubState.SubStates) { if (subState is PlayerStateNode playerSubState) { playerSubState.SetDependencies(playerController); } } } } }
public override void Initialize(StateMachineGraph parentGraph) { base.Initialize(parentGraph); subStates.ForEach(s => s.Initialize(parentGraph)); }
public override void Initialize(StateMachineGraph parentGraph) { base.Initialize(parentGraph); }
public void Setup() { _machine = new InstanceStateMachine(); _graph = _machine.GetGraph(); }
public GameObject GetStateMachineOwner() { StateMachineGraph graph = parentNode.graph as StateMachineGraph; return(graph.GetStateMachineOwner()); }
public StateMachineGraphvizGenerator(StateMachineGraph data) { _graph = CreateAdjacencyGraph(data); }
protected virtual void InjectNodeDependencies(StateMachineGraph stateMachine) { }
public static void TestShowVisualizer(StateMachineGraph data) { var visualizerHost = new VisualizerDevelopmentHost(data, typeof(StateMachineDebugVisualizer)); visualizerHost.ShowVisualizer(); }
public StateMachineGraphvizGenerator(StateMachineGraph data) { _graph = CreateAdjacencyGraph(data); }
protected ServiceBase(SerializationInfo info, StreamingContext context) { this._stateMachine = (StateMachineGraph <ServiceStateEnum, ServiceTriggersEnum>)info.GetValue("_stateMachine", typeof(StateMachineGraph <ServiceStateEnum, ServiceTriggersEnum>)); }
protected ServiceBase(SerializationInfo info, StreamingContext context) { this._stateMachine = (StateMachineGraph<ServiceStateEnum, ServiceTriggersEnum>)info.GetValue("_stateMachine", typeof(StateMachineGraph<ServiceStateEnum, ServiceTriggersEnum>)); }