public ChoiceStateTest(String name)
            : base(name, new NSFEventThread(name))
        {
            // Events
            evaluateEvent = new NSFEvent("EvaluateEvent", this);
            waitEvent = new NSFEvent("WaitEvent", this);

            // Regions and states, from outer to inner
            initialChoiceStateTestState = new NSFInitialState("InitialChoiceStateTest", this);
            waitToEvaluateState = new NSFCompositeState("WaitToEvaluate", this, null, null);
            evaluateValueState = new NSFChoiceState("EvaluateValue", this);
            evaluatedState = new NSFCompositeState("Evaluated", this, null, null);
            initialEvaluatedState = new NSFInitialState("InitialEvaluatedState", evaluatedState);
            valueLowState = new NSFCompositeState("ValueLow", evaluatedState, null, null);
            valueMiddleState = new NSFCompositeState("ValueMiddle", evaluatedState, null, null);
            valueHighState = new NSFCompositeState("ValueHigh", evaluatedState, null, null);

            // Transitions, ordered internal, local, external
            initialChoiceStateTestToWaitToEvaluateTransition = new NSFExternalTransition("InitialChoiceStateTestToWaitToEvaluate", initialChoiceStateTestState, waitToEvaluateState, null, null, null);
            waitToEvaluateToEvaluateValueTransition = new NSFExternalTransition("State1ToState2", waitToEvaluateState, evaluateValueState, evaluateEvent, null, null);
            //waitToEvaluateToEvaluateValueTransition = new NSFExternalTransition("State1ToState2", waitToEvaluateState, evaluatedState, evaluateEvent, null, null);
            initialEvaluatedToValueLowTransition = new NSFExternalTransition("InitialEvaluatedToValueLowTransition", initialEvaluatedState, valueLowState, null, null, null);
            evaluateValueToValueLowTransition = new NSFExternalTransition("EvaluateValueToValueLowTransition", evaluateValueState, valueLowState, null, isValueLow, null);
            evaluateValueToValueMiddleTransition = new NSFExternalTransition("EvaluateValueToValueMiddleTransition", evaluateValueState, valueMiddleState, null, Else, null);
            evaluateValueToValueHighTransition = new NSFExternalTransition("EvaluateValueToValueHighTransition", evaluateValueState, valueHighState, null, isValueHigh, null);
            evaluatedToWaitToEvaluateTransition = new NSFExternalTransition("EvaluatedToWaitToEvaluateTransition", evaluatedState, waitToEvaluateState, waitEvent, null, addValue);
        }
 public State2Strategy(String name, NSFCompositeState parentState)
     : base(name, parentState)
 {
     // Events
     event3 = new NSFEvent("Event3", this);
     // Regions and states, from outer to inner
     intialState2 = new NSFInitialState("IntialState2", this);
     state4 = new NSFCompositeState("state4", this, null, null);
     state5 = new NSFCompositeState("State5", this, null, null);
     // Transitions, ordered internal, local, external
     intialState2ToState4Transition = new NSFExternalTransition("InitialToState4", intialState2, state4, null, null, null);
     state4ToState5Transition = new NSFExternalTransition("State4ToState5", state4, state5, event3, null, null);
 }
 public MultipleTriggersOnTransitionTest(String name)
     : base(name, new NSFEventThread(name))
 {
     event1 = new NSFEvent("Event1", this);
     event2 = new NSFEvent("Event2", this);
     event3 = new NSFEvent("Evnet3", this);
     event4 = new NSFEvent("Event4", this);
     // Regions and states, from outer to inner
     initialState = new NSFInitialState("InitialTest2", this);
     state1 = new NSFCompositeState("State1", this, null, null);
     state2 = new NSFCompositeState("State2", this, null, null);
     // Transitions, ordered internal, local, external
     initialAToState1Transition = new NSFExternalTransition("InitialAToState1", initialState, state1, null, null, null);
     state1ToState2Transition = new NSFExternalTransition("State1ToState2", state1, state2, event1, null, null);
     state2ToState1Transition = new NSFExternalTransition("State2ToState1", state2, state1, event2, null, null);
     state1ToState2Transition.addTrigger(event3);
     state2ToState1Transition.addTrigger(event4);
 }
        public ExceptionHandlingTest(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("InitialTest14", this);
            state1 = new NSFCompositeState("State1", this, null, null);
            state2 = new NSFCompositeState("State2", this, state2EntryActions, null);
            state3 = new NSFCompositeState("State3", this, null, null);
            // Transitions, ordered internal, local, external
            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);
            ExceptionActions += localHandleException;
        }
        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);
        }
        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);
        }
        public ForkJoinToForkJoinTransitionTest(String name)
            : base(name, new NSFEventThread(name))
        {
            // Fork Joins
            bSynch = new NSFForkJoin("BSynch", this);
            abForkJoin = new NSFForkJoin("ABForkJoin", this);
            bcForkJoin = new NSFForkJoin("BCForkJoin", this);
            // ARegion
            // Events
            evA1 = new NSFEvent("EvA1", this);
            // States
            aRegion = new NSFRegion("ARegion", this);
            initialAState = new NSFInitialState("InitialA", aRegion);
            stateA1 = new NSFCompositeState("StateA1", aRegion, null, null);
            stateA2 = new NSFCompositeState("StateA2", aRegion, null, null);
            // Transitions, ordered internal, local, external
            initialAToStateA1Transition = new NSFExternalTransition("InitialAToStateA1", initialAState, stateA1, null, null, null);
            stateA1ToABForkJoinTransition = new NSFExternalTransition("StateA1ToABForkJoin", stateA1, abForkJoin, evA1, null, null);
            abForkJoinToA2Transition = new NSFExternalTransition("ABForkJoinToA2", abForkJoin, stateA2, null, null, null);
            // B Region
            // Events
            evB1 = new NSFEvent("EvB1", this);
            // States
            bRegion = new NSFRegion("BRegion", this);
            initialBState = new NSFInitialState("InitialB", bRegion);
            stateB1 = new NSFCompositeState("StateB1", bRegion, null, null);
            stateB2 = new NSFCompositeState("StateB2", bRegion, null, null);
            // Transitions, ordered internal, local, external
            initialBToStateB1Transition = new NSFExternalTransition("InitialBToStateB1", initialBState, stateB1, null, null, null);
            stateB1ToBSynchTransition = new NSFExternalTransition("StateB1ToBSynch", stateB1, bSynch, evB1, null, null);
            bSynchToStateB2Transition = new NSFExternalTransition("BSynchToStateB2", bSynch, stateB2, null, null, null);
            // C Region
            // Events
            evC1 = new NSFEvent("EvC1", this);
            // States
            cRegion = new NSFRegion("CRegion", this);
            initialCState = new NSFInitialState("InitialC", cRegion);
            stateC1 = new NSFCompositeState("StateC1", cRegion, null, null);
            stateC2 = new NSFCompositeState("StateC2", cRegion, null, null);
            // Transitions, ordered internal, local, external
            initialCToStateC1Transition = new NSFExternalTransition("InitialCToStateC1", initialCState, stateC1, null, null, null);
            stateC1ToBCForkJoinTransition = new NSFExternalTransition("StateC1ToBCForkJoin", stateC1, bcForkJoin, evC1, null, null);
            bcForkJoinToC2Transition = new NSFExternalTransition("BCForkJoinToC2", bcForkJoin, stateC2, null, null, null);

            // Extra Regional Transitions
            bSynchToABForkJoinTransition = new NSFExternalTransition("BSynchToABForkJoin", bSynch, abForkJoin, null, null, null);
            bSynchToBCForkJoinTransition = new NSFExternalTransition("BSynchToBCForkJoin", bSynch, bcForkJoin, null, 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
            commReadyEvent = new NSFEvent("CommReady", this);
            hardwareResetEvent = new NSFEvent("HardwareReset", this);

            // Regions and states, from outer to inner 
            // Initial state construtors take the form (name, parent)
            initialResetStrategyState = new NSFInitialState("InitialResetStrategy", this);
            // Composite state construtors take the form (name, parent, entry action, exit action)
            resetHardwareState = new NSFCompositeState("ResetHardware", this, resetHardwareEntryActions, null);
            reestablishCommunicationsState = new NSFCompositeState("ReestablishCommunications", this, reestablishCommunicationsEntryActions, null);
            readyState = new NSFCompositeState("ThreadReady", this, null, null);

            // Transitions, ordered internal, local, external
            // External transition construtors take the form (name, source, target, trigger, guard, action)
            initialResetStrategyToResetHardwareTransition = new NSFExternalTransition("InitialToResetHardware", initialResetStrategyState, resetHardwareState, null, null, resetVariables);
            resetHardwareToReestablishCommunicationsTransition = new NSFExternalTransition("ResetHardwareToReestablishCommunications", resetHardwareState, reestablishCommunicationsState, null, isHardwareReset, null);
            reestablishCommunicationsStateToReadyTransition = new NSFExternalTransition("ReestablishCommunicationsStateToReady", reestablishCommunicationsState, readyState, null, isCommReady, null);

            // Actions
            resetHardwareAction = new NSFScheduledAction("ReadHardware", resetHardware, EventThread);
            readyCommAction = new NSFScheduledAction("ResetComm", resetComm, EventThread);
        }
        public StrategyTest(String name)
            : base(name, new NSFEventThread(name))
        {
            // Events
            event1 = new NSFEvent("Event1", this);
            event2 = new NSFEvent("Event2", this);

            // Regions and states, from outer to inner
            initialState = new NSFInitialState("InitialTest15", this);
            state1 = new NSFCompositeState("State1", this, null, null);
            state2 = new NSFCompositeState("State2", this, state5EntryActions, null);
            state3 = new NSFCompositeState("State3", this, null, null);
            //Transitions
            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);
            state2Strategy = new State2Strategy("State2Strategy", state2);
        }
        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
            scoutEvent = new NSFEvent("Scout", this, this);

            // Regions and States
            combatInitialState = new NSFInitialState("CombatInitial", this);
            scoutingState = new NSFCompositeState("Scouting", this, null, null);
            scoutingInitialState = new NSFInitialState("ScountingInitial", scoutingState);
            patrolState = new NSFCompositeState("Patrol", scoutingState, null, null);
            moveToEnemyState = new NSFCompositeState("MoveToEnemy", scoutingState, null, null);
            attackChoiceState = new NSFChoiceState("AttackChoice", this);
            attackState = new NSFCompositeState("Attack", this, null, null);

            // Transitions
            combatInitialToScoutingTransition = new NSFExternalTransition("CombatInitialToScouting", combatInitialState, scoutingState, null, null, null);
            scoutingToAttackChoiceTransition = new NSFExternalTransition("ScoutingToAttackChoice", scoutingState, attackChoiceState, scoutEvent, null, null);
            scoutingInitialToPatrolTransition = new NSFExternalTransition("ScoutingInitialToPatrol", scoutingInitialState, patrolState, null, null, null);
            attackChoiceToPatrolTransition = new NSFExternalTransition("AttackChoiceToPatrol", attackChoiceState, patrolState, null, Else, null);
            attackChoiceToAttackTransition = new NSFExternalTransition("AttackChoiceToAttack", attackChoiceState, attackState, null, isEnemyInRange, null);
            attackChoiceToMoveToEnemyTransition = new NSFExternalTransition("AttackChoiceToMoveToEnemy", attackChoiceState, moveToEnemyState, null, isEnemyNear, null);
        }
        public ContinuouslyRunningTest(String name, int myNumberOfRepeatedEvents)
            : base(name, new NSFEventThread(name))
        {
            numberOfRepeatedEvents = myNumberOfRepeatedEvents;

            // Events
            event1 = new NSFEvent("Event1", this);
            event2 = new NSFEvent("Event2", this);
            event3 = new NSFEvent("Event3", this);
            event4 = new NSFDataEvent<string>("Event4", this, "EventFourData");
            event5 = new NSFEvent("Event5", this);
            event6 = new NSFEvent("Event6", this);
            //States
            test2InitialState = new NSFInitialState("InitialTest3", this);
            state1 = new NSFCompositeState("State1", this, state1EntryAction, state1ExitAction);
            state2 = new NSFCompositeState("State2", this, null, null);
            //State 1 Region
            state1InitialState = new NSFInitialState("State1Initial", state1);
            state1History = new NSFDeepHistory("State1History", state1);
            state1_1 = new NSFCompositeState("State1_1", state1, null, null);
            state1_2 = new NSFCompositeState("State1_2", state1, null, null);
            // State1_2 Region
            state1_2InitialState = new NSFInitialState("State1_2Initial", state1_2);
            state1_2_1 = new NSFCompositeState("State1_2_1", state1_2, null, null);
            state1_2_2 = new NSFCompositeState("State1_2_2", state1_2, null, null);
            //Transitions
            // Test1 Region
            test1InitialToState1Transition = new NSFExternalTransition("Test1InitialToState1", test2InitialState, state1, null, null, null);
            state1ToState2Transition = new NSFExternalTransition("State1ToState2", state1, state2, event5, null, null);
            state2ToState1Transition = new NSFExternalTransition("State2ToState1", state2, state1, event6, null, null);
            // State1 Region
            state1InitialToState1HistoryTransition = new NSFExternalTransition("State1InitialToState1History", state1InitialState, state1History, null, null, null);
            state1HistoryToState1_1Transition = new NSFExternalTransition("State1HistoryToState1_1", state1History, state1_1, null, null, null);
            state1_1ToState1_2Transition = new NSFExternalTransition("State1_1ToState1_2", state1_1, state1_2, event1, null, null);
            state1_2ToState1_1Transition = new NSFExternalTransition("State1_2ToState1_1", state1_2, state1_1, event2, null, null);
            // State1_2 Region
            state1_2InitialStateToState1_2_1Transition = new NSFExternalTransition("State1_2InitialStateToState1_2_1", state1_2InitialState, state1_2_1, null, null, null);
            state1_2_1ToState1_2_2Transition = new NSFExternalTransition("State1_2_1ToState1_2_2", state1_2_1, state1_2_2, event3, null, null);
            state1_2_2ToState1_2_1Transition = new NSFExternalTransition("State1_2_2ToState1_2_1", state1_2_2, state1_2_1, event4, 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.
            // Maintain the same order of declaration and initialization.

            // Events
            // Event constructors take the form (name, parent)
            cycleEvent = new NSFEvent("CycleEvent", this);
            aReadyEvent = new NSFEvent("AReadyEvent", this);
            bReadyEvent = new NSFEvent("BReadyEvent", this);
            aCompleteEvent = new NSFEvent("ACompleteEvent", this);
            bCompleteEvent = new NSFEvent("BCompleteEvent", this);

            // Regions and states, from outer to inner
            systemRegion = new NSFRegion("SystemRegion", this);
            subsystemARegion = new NSFRegion("SubsystemARegion", this);
            subsystemBRegion = new NSFRegion("SubsystemBRegion", this);
            initializeForkJoin = new NSFForkJoin("InitializeForkJoin", this);
            cycleForkJoin = new NSFForkJoin("CycleForkJoin", this);
            completeForkJoin = new NSFForkJoin("CompleteForkJoin", this);

            // System Region
            // Regions and states, from outer to inner
            // Initial state construtors take the form (name, parent)
            systemInitialState = new NSFInitialState("SystemInitial", systemRegion);
            // Composite state construtors take the form (name, parent, entry actions, exit actions)
            waitForCycleEventState = new NSFCompositeState("WaitForCycleEvent", systemRegion, null, null);
            // Transitions, ordered internal, local, external
            // External transition construtors take the form (name, source, target, trigger, guard, action)
            systemInitialToInitializeForkJoinTransition = new NSFExternalTransition("SystemInitialToInitializeForkJoin", systemInitialState, initializeForkJoin, null, null, null);
            initializeForkJoinToWaitForCycleEventTransition = new NSFExternalTransition("InitializeForkJoinToWaitForCycleEvent", initializeForkJoin, waitForCycleEventState, null, null, null);
            waitForCycleEventToCycleForkJoinTransition = new NSFExternalTransition("WaitForCycleEventToCycleForkJoin", waitForCycleEventState, cycleForkJoin, cycleEvent, null, null);
            cycleForkJoinToCompleteForkJoinTransiiton = new NSFForkJoinTransition("CycleForkJoinToCompleteForkJoin", cycleForkJoin, completeForkJoin, systemRegion, null);
            completeForkJoinToWaitForCycleEventTransition = new NSFExternalTransition("CompleteForkJoinToWaitForCycleEvent", completeForkJoin, waitForCycleEventState, null, null, null);

            // Subystem A Region
            // Regions and states, from outer to inner
            // Initial state construtors take the form (name, parent)
            subsystemAInitialState = new NSFInitialState("SubsystemAInitial", subsystemARegion);
            // Composite state construtors take the form (name, parent, entry actions, exit actions)
            initializeAState = new NSFCompositeState("InitializeA", subsystemARegion, initializeAEntryActions, null);
            cycleAState = new NSFCompositeState("CycleA", subsystemARegion, cycleAEntryActions, null);
            // Transitions, ordered internal, local, external
            // External transition construtors take the form (name, source, target, trigger, guard, action)
            subsystemAInitialToInitializeATransition = new NSFExternalTransition("SubsystemAInitialToInitializeA", subsystemAInitialState, initializeAState, null, null, null);
            initializeAToInitializeForkJoinTransition = new NSFExternalTransition("InitializeAToInitializeForkJoin", initializeAState, initializeForkJoin, aReadyEvent, null, null);
            initializeForkJoinToCycleForkJoinARegionTransition = new NSFForkJoinTransition("InitializeForkJoinToCycleForkJoinARegion", initializeForkJoin, cycleForkJoin, subsystemARegion, null);
            cycleForkJoinToCycleATransition = new NSFExternalTransition("CycleForkJoinToCycleA", cycleForkJoin, cycleAState, null, null, null);
            cycleAToCompleteForkJoinTransition = new NSFExternalTransition("CycleAToCompleteForkJoin", cycleAState, completeForkJoin, aCompleteEvent, null, null);

            // Subystem B Region
            // Regions and states, from outer to inner
            // Initial state construtors take the form (name, parent)
            subsystemBInitialState = new NSFInitialState("SubsystemBInitial", subsystemBRegion);
            // Composite state construtors take the form (name, parent, entry actions, exit actions)
            initializeBState = new NSFCompositeState("InitializeB", subsystemBRegion, initializeBEntryActions, null);
            cycleBState = new NSFCompositeState("CycleB", subsystemBRegion, cycleBEntryActions, null);
            // Transitions, ordered internal, local, external
            // External transition construtors take the form (name, source, target, trigger, guard, action)
            subsystemBInitialToInitializeBTransition = new NSFExternalTransition("SubsystemBInitialToInitializeB", subsystemBInitialState, initializeBState, null, null, null);
            initializeBToInitializeForkJoinTransition = new NSFExternalTransition("InitializeBToInitializeForkJoin", initializeBState, initializeForkJoin, bReadyEvent, null, null);
            initializeForkJoinToCycleForkJoinBRegionTransition = new NSFForkJoinTransition("InitializeForkJoinToCycleForkJoinBRegion", initializeForkJoin, cycleForkJoin, subsystemBRegion, null);
            cycleForkJoinToCycleBTransition = new NSFExternalTransition("CycleForkJoinToCycleB", cycleForkJoin, cycleBState, null, null, null);
            cycleBToCompleteForkJoinTransition = new NSFExternalTransition("CycleBToCompleteForkJoin", cycleBState, completeForkJoin, bCompleteEvent, null, null);
        }
 /// <summary>
 /// Adds an outgoing transition.
 /// </summary>
 /// <param name="transition">The outgoing transition to add.</param>
 /// <remarks>
 /// This method is called from the external transition class constructor.
 /// </remarks>
 internal void addOutgoingTransition(NSFExternalTransition transition)
 {
     outgoingTransitions.Add(transition);
 }
 public DeepHistoryTest(String name)
     : base(name, new NSFEventThread(name))
 {
     // Events
     event1 = new NSFEvent("Event1", this);
     event2 = new NSFEvent("Event2", this);
     event3 = new NSFEvent("Event3", this);
     event4 = new NSFEvent("Event4", this);
     event5 = new NSFEvent("Event5", this);
     event6 = new NSFEvent("Event6", this);
     //States
     test2InitialState = new NSFInitialState("InitialTest3", this);
     state1 = new NSFCompositeState("State1", this, null, null);
     state2 = new NSFCompositeState("State2", this, null, null);
     //State 1 Region
     state1InitialState = new NSFInitialState("State1Initial", state1);
     state1History = new NSFDeepHistory("State1History", state1);
     state1_1 = new NSFCompositeState("State1_1", state1, null, null);
     state1_2 = new NSFCompositeState("State1_2", state1, null, null);
     // State1_2 Region
     state1_2InitialState = new NSFInitialState("State1_2Initial", state1_2);
     state1_2_1 = new NSFCompositeState("State1_2_1", state1_2, null, null);
     state1_2_2 = new NSFCompositeState("State1_2_2", state1_2, null, null);
     //Transitions
     // Test1 Region
     test1InitialToState1Transition = new NSFExternalTransition("Test1InitialToState1", test2InitialState, state1, null, null, null);
     state1ToState2Transition = new NSFExternalTransition("State1ToState2", state1, state2, event5, null, null);
     state2ToState1Transition = new NSFExternalTransition("State2ToState1", state2, state1, event6, null, null);
     // State1 Region
     state1InitialToState1HistoryTransition = new NSFExternalTransition("State1InitialToState1History", state1InitialState, state1History, null, null, null);
     state1HistoryToState1_1Transition = new NSFExternalTransition("State1HistoryToState1_1", state1History, state1_1, null, null, null);
     state1_1ToState1_2Transition = new NSFExternalTransition("State1_1ToState1_2", state1_1, state1_2, event1, null, null);
     state1_2ToState1_1Transition = new NSFExternalTransition("State1_2ToState1_1", state1_2, state1_1, event2, null, null);
     // State1_2 Region
     state1_2InitialStateToState1_2_1Transition = new NSFExternalTransition("State1_2InitialStateToState1_2_1", state1_2InitialState, state1_2_1, null, null, null);
     state1_2_1ToState1_2_2Transition = new NSFExternalTransition("State1_2_1ToState1_2_2", state1_2_1, state1_2_2, event3, null, null);
     state1_2_2ToState1_2_1Transition = new NSFExternalTransition("State1_2_2ToState1_2_1", state1_2_2, state1_2_1, event4, 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);
        }
 /// <summary>
 /// Adds an outgoing transition.
 /// </summary>
 /// <param name="transition">The outgoing transition to add.</param>
 /// <remarks>
 /// This method is called from the external transition class constructor.
 /// </remarks>
 internal void addOutgoingTransition(NSFExternalTransition transition)
 {
     outgoingTransitions.Add(transition);
 }
        private void createStateMachine()
        {
            // Event ructors take the form (name, parent)
            breakEvent = new NSFEvent("Break", this);
            breakOverEvent = new NSFEvent("BreakOver", this);
            milestoneMetEvent = new NSFEvent("MilestoneMet", this);
            backToWorkEvent = new NSFEvent("BackToWork", this);

            // Regions and states, from outer to inner
            // Initial state rutors take the form (name, parent)
            workHardPlayHardInitialState = new NSFInitialState("WorkHardPlayHardInitial", this);
            // Composite state rutors take the form (name, parent, entry actions, exit actions)
            takeABreakState = new NSFCompositeState("TakeABreak", this, null, null);
            breakOverState = new NSFCompositeState("BreakOver", this, null, null);
            breakOverInitialState = new NSFInitialState("BreakOverInitial", breakOverState);
            breakOverHistoryState = new NSFDeepHistory("BreakOverHistory", breakOverState);
            workHardState = new NSFCompositeState("WorkHard", breakOverState, null, null);
            playHardState = new NSFCompositeState("PlayHard", breakOverState, null, null);

            // Transitions, ordered internal, local, external
            // External transition rutors take the form (name, source, target, trigger, guard, action)
            workHardPlayHardInitialToBreakOverTransition = new NSFExternalTransition("WorkHardPlayHardInitialToBreakOver", workHardPlayHardInitialState, breakOverState, null, null, null);
            takeABreakToBreakOverTransition = new NSFExternalTransition("TakeABreakToBreakOver", takeABreakState, breakOverState, breakOverEvent, null, null);
            breakOverToTakeABreakTransition = new NSFExternalTransition("BreakOverToTakeABreak", breakOverState, takeABreakState, breakEvent, null, null);
            breakOverInitialToBreakOverHistoryTransition = new NSFExternalTransition("BreakOverInitialToBreakOverHistory", breakOverInitialState, breakOverHistoryState, null, null, null);
            breakOverHistoryToWorkHardTransition = new NSFExternalTransition("BreakOverHistoryToWorkHard", breakOverHistoryState, workHardState, null, null, null);
            workHardToPlayHardTransition = new NSFExternalTransition("WorkHardToPlayHard", workHardState, playHardState, milestoneMetEvent, null, null);
            playHardToWorkHardTransition = new NSFExternalTransition("PlayHardToWorkHard", playHardState, workHardState, backToWorkEvent, null, null);
        }