/// <summary> /// Adds an outgoing transition. /// </summary> /// <param name="transition">The outgoing transition to add.</param> /// <remarks> /// This method is called from the internal transition class constructor. /// </remarks> internal void addOutgoingTransition(NSFInternalTransition transition) { // Insert before first transition that is not internal foreach (NSFTransition outgoingTransition in outgoingTransitions) { if (outgoingTransition is NSFInternalTransition) { outgoingTransitions.Insert(outgoingTransitions.IndexOf(outgoingTransition), transition); return; } } outgoingTransitions.Add(transition); }
public ExtendedRunTest(String name) : base(name, new NSFEventThread(name)) { event1 = new NSFEvent("Event1", this); event2 = new NSFEvent("Event2", this); // Regions and states, from outer to inner initialState = new NSFInitialState("InitialTest1", this); state1 = new NSFCompositeState("State1", this, null, null); state2 = new NSFCompositeState("State2", this, null, null); state3 = new NSFCompositeState("State3", this, null, null); // Transitions, ordered internal, local, external state2ReactionToEvent1 = new NSFInternalTransition("State2ReactionToEvent1", state2, event1, null, state2ReactionToEvent1Actions); test1ReactionToEvent2 = new NSFInternalTransition("Test1ReactionToEvent2", this, event2, null, test13ReactionToEvent2Actions); initialToState1Transition = new NSFExternalTransition("InitialToState1", initialState, state1, null, null, null); state1ToState2Transition = new NSFExternalTransition("State1ToState2", state1, state2, event1, null, null); state2ToState3Transition = new NSFExternalTransition("State2ToState3", state2, state3, event2, null, null); state3ToState2Transition = new NSFExternalTransition("State3ToState2", state3, state2, event1, null, null); state2ToState1Transition = new NSFExternalTransition("State2ToState1", state2, state1, event1, null, null); }
public TransitionOrderTest(String name) : base(name, new NSFEventThread(name)) { // Events event1 = new NSFEvent("Event1", this); event2 = new NSFEvent("Event2", this); event3 = new NSFEvent("Event3", this); // Regions and states, from outer to inner initialTest15 = new NSFInitialState("InitialTest16", this); state1 = new NSFCompositeState("State1", this, null, null); state2 = new NSFCompositeState("State2", this, null, null); intialState2 = new NSFInitialState("IntialState2", state2); state2_1 = new NSFCompositeState("State2_1", state2, null, state2_1ExitActions); state3 = new NSFCompositeState("State3", this, null, null); initialState3 = new NSFInitialState("InitialState3", state3); state3_1 = new NSFCompositeState("State3_1", state3, null, state3_1ExitActions); state4 = new NSFCompositeState("State4", this, null, null); errorState = new NSFCompositeState("Error", this, null, null); // Transitions, ordered internal, local, external initialTest15ToState1Transition = new NSFExternalTransition("InitialTest15ToState1", initialTest15, state1, null, null, null); state1ToState2Transition = new NSFExternalTransition("State1ToState2", state1, state2, event2, null, null); state1ReactionToEvent1 = new NSFInternalTransition("State1ReactionToEvent1", state1, event1, null, state1ReactionToEvent1Actions); state1ToErrorTransition = new NSFExternalTransition("State1ToError", state1, errorState, event1, null, null); state2ToState3Transition = new NSFExternalTransition("State2ToState3Transition", state2, state3, event2, null, null); state2ToErrorTransition = new NSFExternalTransition("State2ToErrorTransition", state2, errorState, event1, null, null); state2ToState2Transition = new NSFLocalTransition("State2ToState2Transition", state2, state2, event1, null, null); intialState2ToState2_1Transition = new NSFExternalTransition("intialState2ToState2_1Transition", intialState2, state2_1, null, null, null); state3ToState4Transition = new NSFExternalTransition("State3ToState4Transition", state3, state4, event2, null, null); state3ToState3Transition = new NSFLocalTransition("State3ToState3Transition", state3, state3, event1, null, null); state3ReactionToEvent1 = new NSFInternalTransition("state3ReactionToEvent1", state3, event1, null, state3ReactionToEvent1Actions); initialState3ToState3_1Transition = new NSFExternalTransition("InitialState3ToState3_1Transition", initialState3, state3_1, null, null, null); state3ToErrorTransition = new NSFExternalTransition("State3ToErrorTransition", state3, errorState, event3, null, null); }
private void createStateMachine() { // State Machine Components // Define and initialize in the order: // 1) Events // 2) Regions and states, from outer to inner // 3) Transitions, ordered internal, local, external // 4) Group states and transitions within a region together. // Events // Event constructors take the form (name, parent) // Data event constructors take the form (name, parent, data payload) newCommandEvent = new NSFDataEvent<String>("NewCommand", this, "CommandPayload"); newResponseEvent = new NSFDataEvent<String>("NewResponse", this, "ResponsePayload"); responseTimeoutEvent = new NSFEvent("ResponseTimeout", this); resetEvent = new NSFEvent("Reset", this); // Regions and states, from outer to inner // Initial state construtors take the form (name, parent) initialCommandProcessorState = new NSFInitialState("InitialCommandProcessor", this); // Composite state construtors take the form (name, parent, entry action, exit action) waitForCommandState = new NSFCompositeState("WaitForCommand", this, null, null); waitForResponseState = new NSFCompositeState("WaitForResponse", this, waitForResponseEntryActions, waitForResponseExitActions); errorState = new NSFCompositeState("Error", this, errorEntryActions, null); resetState = new NSFCompositeState("Reset", this, resetEntryActions, null); // Transitions, ordered internal, local, external // Internal transition construtors take the form (name, state, trigger, guard, action) reactionToNewCommand = new NSFInternalTransition("ReactionToNewCommand", this, newCommandEvent, null, queueCommand); // External transition construtors take the form (name, source, target, trigger, guard, action) initialCommandProcessorToWaitForCommandTransition = new NSFExternalTransition("InitialToWaitForCommand", initialCommandProcessorState, waitForCommandState, null, null, null); waitForCommandToWaitForResponseTransition = new NSFExternalTransition("WaitForCommandToWaitForResponse", waitForCommandState, waitForResponseState, null, hasCommand, sendCommand); waitForResponseToWaitForCommandTransition = new NSFExternalTransition("WaitForResponseToWaitForCommand", waitForResponseState, waitForCommandState, newResponseEvent, isResponse, handleResponse); waitForResponseToErrorTransition = new NSFExternalTransition("WaitForResponseToError", waitForResponseState, errorState, responseTimeoutEvent, null, null); errorToResetTransition = new NSFExternalTransition("ErrorToReset", errorState, resetState, resetEvent, null, null); resetToWaitForCommandTransition = new NSFExternalTransition("ResetToWaitForCommand", resetState, waitForCommandState, null, isReady, null); }
private void createStateMachine() { waitForResponseReactionToResponseTimeout = new NSFInternalTransition("WaitForResponseReactionToResponseTimeout", waitForResponseState, responseTimeoutEvent, canRetry, retrySend); waitForResponseState.EntryActions += waitForResponseEntryActions; }