Exemplo n.º 1
0
        public BasicForkJoinTest(String name)
            : base(name, new NSFEventThread(name))
        {
            // Events
            event1 = new NSFEvent("Event1", this);
            event2 = new NSFEvent("Event2", this);

            //States
            // Region A
            regionA       = new NSFRegion("RegionA", this);
            initialAState = new NSFInitialState("InitialA", regionA);
            stateA1       = new NSFCompositeState("StateA1", regionA, null, null);
            stateA2       = new NSFCompositeState("StateA2", regionA, null, null);

            // Region B
            regionB       = new NSFRegion("RegionB", this);
            initialBState = new NSFInitialState("InitialB", regionB);
            stateB1       = new NSFCompositeState("StateB1", regionB, null, null);
            stateB2       = new NSFCompositeState("StateB2", regionB, null, null);

            // ForkJoins
            abForkJoin = new NSFForkJoin("ABForkJoin", this);

            // Transitions, ordered internal, local, external
            // Region A
            initialAStateToStateA1Transition = new NSFExternalTransition("InitialAStateToStateA1", initialAState, stateA1, null, null, null);
            stateA1ToABForkJoinTransition    = new NSFExternalTransition("StateA1ToABForkJoin", stateA1, abForkJoin, event1, null, null);
            abForkJoinToStateA2Transition    = new NSFExternalTransition("AbForkJoinToStateA2", abForkJoin, stateA2, null, null, null);

            // Region B
            initialBStateToStateB1Transition = new NSFExternalTransition("InitialBStateToStateB1", initialBState, stateB1, null, null, null);
            stateB1ToABForkJoinTransition    = new NSFExternalTransition("StateB1ToABForkJoin", stateB1, abForkJoin, event2, null, null);
            abForkJoinToStateB2Transition    = new NSFExternalTransition("AbForkJoinToStateB2", abForkJoin, stateB2, null, null, null);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }