Examples of newUntypedStateMachine()


Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        final UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(Issue17StateMachine.class);
        builder.defineSequentialStatesOn(Issue17State.A, Issue17State.A1, Issue17State.A2);
        builder.internalTransition().within(Issue17State.A).on(Issue17Event.SAME).callMethod("onSameWithinA");
        builder.localTransition().from(Issue17State.A1).to(Issue17State.A2).on(Issue17Event.NEXT).callMethod("onA1ToA2");
       
        Issue17StateMachine fsm = builder.newUntypedStateMachine(Issue17State.A);
        fsm.addTransitionDeclinedListener(new TransitionDeclinedListener<UntypedStateMachine, Object, Object, Object>() {
            @Override
            public void transitionDeclined(
                    TransitionDeclinedEvent<UntypedStateMachine, Object, Object, Object> event) {
                System.out.println("Transition declined from state "+event.getSourceState()+" on event "+event.getCause());
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        final UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(Issue16StateMachine.class);
        builder.defineTimedState(Issue16State.A, 100, 0, Issue16Event.A2A, null);
        builder.transition().from(Issue16State.A).to(Issue16State.A).on(Issue16Event.A2A);
        builder.transition().from(Issue16State.A).to(Issue16State.B).on(Issue16Event.A2B);
       
        Issue16StateMachine fsm = builder.newUntypedStateMachine(Issue16State.A);
        fsm.addTransitionDeclinedListener(new TransitionDeclinedListener<UntypedStateMachine, Object, Object, Object>() {
            @Override
            public void transitionDeclined(TransitionDeclinedEvent<UntypedStateMachine, Object, Object, Object> event) {
                System.out.println("Transition from "+event.getSourceState()+" on event "+event.getCause()+" is declined.");
                timedEventTriggered.set(true);
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        builder.externalTransition(10).from(Issue18State.B).to(Issue18State.A).on(Issue18Event.GO).
                when(new CounterCondition(5, "Count_5_B")).callMethod("onB2A");
        builder.internalTransition(1).within(Issue18State.B).on(Issue18Event.GO).callMethod("onB2B");

        Issue18StateMachine fsm = builder.newUntypedStateMachine(Issue18State.A);
        fsm.start();
        fsm.fire(Issue18Event.GO);
        fsm.fire(Issue18Event.GO);
        fsm.fire(Issue18Event.GO);
        fsm.fire(Issue18Event.GO);
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        builder.defineTimedState(SnakeState.UP, 0, GameConfigure.FRAME_TIME, SnakeEvent.MOVE_AHEAD, gameModel);
        builder.defineTimedState(SnakeState.DOWN, 0, GameConfigure.FRAME_TIME, SnakeEvent.MOVE_AHEAD, gameModel);
        builder.defineTimedState(SnakeState.RIGHT, 0, GameConfigure.FRAME_TIME, SnakeEvent.MOVE_AHEAD, gameModel);
        builder.defineTimedState(SnakeState.LEFT, 0, GameConfigure.FRAME_TIME, SnakeEvent.MOVE_AHEAD, gameModel);
       
        SnakeController controller = builder.newUntypedStateMachine(SnakeState.NEW);
        final SnakeGame game = new SnakeGame(controller, gameModel);
        controller.addTransitionCompleteListener(new StateMachine.TransitionCompleteListener<UntypedStateMachine, Object, Object, Object>() {
            @Override
            public void transitionComplete(TransitionCompleteEvent<UntypedStateMachine, Object, Object, Object> event) {
                game.repaint();
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        // use local transition avoid invoking state A exit functions when entering its decision state
        builder.localTransitions().between(DecisionState.A).and(DecisionState._A).
                onMutual(DecisionEvent.A2ANY, DecisionEvent.ANY2A).
                perform(Lists.newArrayList(decisionMaker, null));

        fsm = builder.newUntypedStateMachine(DecisionState.A);
        return fsm;
    }

    @Test
    public void testDecisionStateMachine() {
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

        builder.externalTransition().from("D").to("A").on(FSMEvent.ToA);
        builder.externalTransition().from("A").to("B").on(FSMEvent.ToB);
        builder.externalTransition().from("B").to("C").on(FSMEvent.ToC);
        builder.externalTransition().from("C").to("D").on(FSMEvent.ToD);
       
        final StateMachineSample fsm = builder.newUntypedStateMachine("D");
        fsm.addDeclarativeListener(new TestListener());
        String expected1 = (String) fsm.test(FSMEvent.ToA, 5);
        System.out.println("expected1: "+expected1);
        assertThat(expected1, equalTo("A"));
        String expected2 = (String) fsm.test(FSMEvent.ToA, 11);
View Full Code Here

Examples of org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newUntypedStateMachine()

   
    @Test
    public void testThreadLocal() {
        UntypedStateMachineBuilder builder = StateMachineBuilderFactory.create(StateMachineSample.class);
        builder.externalTransition().from("A").to("B").on(FSMEvent.ToB).callMethod("onAToB");
        final StateMachineSample fsm = builder.newUntypedStateMachine("A");
        assertTrue(StateMachineContext.currentInstance()==null);
        fsm.fire(FSMEvent.ToB, 10);
        assertTrue(fsm==fsm.currentInstance);
        assertTrue(StateMachineContext.currentInstance()==null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.