/// <summary>
 /// Adds a region to the composite state.
 /// </summary>
 /// <param name="region">The region to add.</param>
 internal void addRegion(NSFRegion region)
 {
     if (!regions.Contains(region))
     {
         regions.Add(region);
     }
 }
 /// <summary>
 /// Gets the composite state's default region.
 /// </summary>
 internal NSFRegion getDefaultRegion()
 {
     if (defaultRegion == null)
     {
         defaultRegion = new NSFRegion(Name + "DefaultRegion", this);
     }
     return(defaultRegion);
 }
        /// <summary>
        /// Creates a state.
        /// </summary>
        /// <param name="name">The name of the state.</param>
        /// <param name="parentRegion">The parent region of the state.</param>
        /// <param name="entryAction">The actions to be performed upon entry to the state.</param>
        /// <param name="exitAction">The actions to be performed upon exit of the state.</param>
        public NSFState(NSFString name, NSFRegion parentRegion, NSFVoidAction<NSFStateMachineContext> entryAction, NSFVoidAction<NSFStateMachineContext> exitAction)
            : base(name)
        {
            this.parentRegion = parentRegion;
            EntryActions += entryAction;
            ExitActions += exitAction;

            if (parentRegion != null)
            {
                parentRegion.addSubstate(this);
            }

            EntryActions.setExceptionAction(handleEntryActionException);
            ExitActions.setExceptionAction(handleExitActionException);
        }
        /// <summary>
        /// Creates a state.
        /// </summary>
        /// <param name="name">The name of the state.</param>
        /// <param name="parentRegion">The parent region of the state.</param>
        /// <param name="entryAction">The actions to be performed upon entry to the state.</param>
        /// <param name="exitAction">The actions to be performed upon exit of the state.</param>
        public NSFState(NSFString name, NSFRegion parentRegion, NSFVoidAction <NSFStateMachineContext> entryAction, NSFVoidAction <NSFStateMachineContext> exitAction)
            : base(name)
        {
            this.parentRegion = parentRegion;
            EntryActions     += entryAction;
            ExitActions      += exitAction;

            if (parentRegion != null)
            {
                parentRegion.addSubstate(this);
            }

            EntryActions.setExceptionAction(handleEntryActionException);
            ExitActions.setExceptionAction(handleExitActionException);
        }
 public ResetStrategy(String name, NSFRegion parentRegion)
     : base(name, parentRegion)
 {
     createStateMachine();
 }
 /// <summary>
 /// Creates a composite state.
 /// </summary>
 /// <param name="name">The name of the composite state.</param>
 /// <param name="parentRegion">The parent region of the composite state.</param>
 /// <param name="entryAction">The actions to be performed upon entry to the composite state.</param>
 /// <param name="exitAction">The actions to be performed upon exit of the composite state.</param>
 public NSFCompositeState(NSFString name, NSFRegion parentRegion, NSFVoidAction<NSFStateMachineContext> entryAction, NSFVoidAction<NSFStateMachineContext> exitAction)
     : base(name, parentRegion, entryAction, exitAction)
 {
 }
 /// <summary>
 /// Gets the composite state's default region.
 /// </summary>
 internal NSFRegion getDefaultRegion()
 {
     if (defaultRegion == null)
     {
         defaultRegion = new NSFRegion(Name + "DefaultRegion", this);
     }
     return defaultRegion;
 }
 /// <summary>
 /// Indicates if the fork-join is the active substate within the specified region.
 /// </summary>
 /// <param name="region">The region in question.</param>
 /// <returns>True if the fork-join is the active substate, otherwise false.</returns>
 public bool isActive(NSFRegion region)
 {
     return(region.isInState(this));
 }
 /// <summary>
 /// Creates an initial pseudo-state.
 /// </summary>
 /// <param name="name">The name of the initial pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the initial pseudo-state.</param>
 public NSFInitialState(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
 }
 /// <summary>
 /// Creates a choice pseudo-state.
 /// </summary>
 /// <param name="name">The name of the choice pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the choice pseudo-state.</param>
 public NSFChoiceState(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
 }
예제 #11
0
 /// <summary>
 /// Creates a deep history pseudo-state.
 /// </summary>
 /// <param name="name">The name of the deep history pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the deep history pseudo-state.</param>
 public NSFDeepHistory(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, 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);
        }
예제 #13
0
 /// <summary>
 /// Creates a state machine.
 /// </summary>
 /// <param name="name">The user defined name for the state machine.</param>
 /// <param name="parentRegion">The parent region of the state machine.</param>
 public NSFStateMachine(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
     construct(TopStateMachine.EventThread);
 }
 /// <summary>
 /// Creates a composite state.
 /// </summary>
 /// <param name="name">The name of the composite state.</param>
 /// <param name="parentRegion">The parent region of the composite state.</param>
 /// <param name="entryAction">The actions to be performed upon entry to the composite state.</param>
 /// <param name="exitAction">The actions to be performed upon exit of the composite state.</param>
 public NSFCompositeState(NSFString name, NSFRegion parentRegion, NSFVoidAction <NSFStateMachineContext> entryAction, NSFVoidAction <NSFStateMachineContext> exitAction)
     : base(name, parentRegion, entryAction, exitAction)
 {
 }
        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);
        }
 /// <summary>
 /// Creates an initial pseudo-state.
 /// </summary>
 /// <param name="name">The name of the initial pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the initial pseudo-state.</param>
 public NSFInitialState(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
 }
 /// <summary>
 /// Creates a transition between two fork-joins.
 /// </summary>
 /// <param name="name">User assigned name for transition.</param>
 /// <param name="source">Transition source.</param>
 /// <param name="target">Transition target.</param>
 /// <param name="region">Transition region.</param>
 /// <param name="action">Transition action.</param>
 /// <remarks>
 /// This class is an extension to UML 2.x.  It allows a transition to be made between two fork-joins,
 /// optionally specifying a region associated with the transition.  If a region is specified, its
 /// active substate will be the target fork-join after the transition is taken.  If a NULL region is
 /// specified, then no region's active substate will be the target fork-join as a result of taking
 /// this transition.  This latter case, where the associated region is NULL, is equivalent to using
 /// an external transition between the two fork-joins.
 /// </remarks>
 public NSFForkJoinTransition(NSFString name, NSFForkJoin source, NSFForkJoin target, NSFRegion region, NSFVoidAction <NSFStateMachineContext> action)
     : base(name, source, target, null, null, action)
 {
     ForkJoinRegion = region;
 }
 /// <summary>
 /// Creates a transition between two fork-joins.
 /// </summary>
 /// <param name="name">User assigned name for transition.</param>
 /// <param name="source">Transition source.</param>
 /// <param name="target">Transition target.</param>
 /// <param name="region">Transition region.</param>
 /// <param name="action">Transition action.</param>
 /// <remarks>
 /// This class is an extension to UML 2.x.  It allows a transition to be made between two fork-joins,
 /// optionally specifying a region associated with the transition.  If a region is specified, its
 /// active substate will be the target fork-join after the transition is taken.  If a NULL region is
 /// specified, then no region's active substate will be the target fork-join as a result of taking 
 /// this transition.  This latter case, where the associated region is NULL, is equivalent to using
 /// an external transition between the two fork-joins.
 /// </remarks>
 public NSFForkJoinTransition(NSFString name, NSFForkJoin source, NSFForkJoin target, NSFRegion region, NSFVoidAction<NSFStateMachineContext> action)
     : base(name, source, target, null, null, action)
 {
     ForkJoinRegion = region;
 }
 /// <summary>
 /// Creates a choice pseudo-state.
 /// </summary>
 /// <param name="name">The name of the choice pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the choice pseudo-state.</param>
 public NSFChoiceState(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
 }
 /// <summary>
 /// Creates a state machine.
 /// </summary>
 /// <param name="name">The user defined name for the state machine.</param>
 /// <param name="parentRegion">The parent region of the state machine.</param>
 public NSFStateMachine(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
     construct(TopStateMachine.EventThread);
 }
 /// <summary>
 /// Indicates if the fork-join is the active substate within the specified region.
 /// </summary>
 /// <param name="region">The region in question.</param>
 /// <returns>True if the fork-join is the active substate, otherwise false.</returns>
 public bool isActive(NSFRegion region)
 {
     return region.isInState(this);
 }
 /// <summary>
 /// Adds a region to the composite state.
 /// </summary>
 /// <param name="region">The region to add.</param>
 internal void addRegion(NSFRegion region)
 {
     if (!regions.Contains(region))
     {
         regions.Add(region);
     }
 }
 /// <summary>
 /// Creates a shallow history pseudo-state.
 /// </summary>
 /// <param name="name">The name of the shallow history pseudo-state.</param>
 /// <param name="parentRegion">The parent region of the shallow history pseudo-state.</param>
 public NSFShallowHistory(NSFString name, NSFRegion parentRegion)
     : base(name, parentRegion, null, null)
 {
 }