本文整理匯總了Java中org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java UntypedStateMachineBuilder類的具體用法?Java UntypedStateMachineBuilder怎麽用?Java UntypedStateMachineBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
UntypedStateMachineBuilder類屬於org.squirrelframework.foundation.fsm包,在下文中一共展示了UntypedStateMachineBuilder類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test902HelloSquirrel
import org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder; //導入依賴的package包/類
private void test902HelloSquirrel() {
// 3. Build State Transitions
UntypedStateMachineBuilder builder = StateMachineBuilderFactory
.create(StateMachineSample.class);
builder.externalTransition().from(FSMState.A).to(FSMState.B)
.on(FSMEvent.ToB).callMethod("fromAToB");
builder.externalTransition().from(FSMState.B).to(FSMState.C)
.on(FSMEvent.ToC).callMethod("fromBToC");
builder.onEntry(FSMState.B).callMethod("ontoB");
// 4. Use State Machine
UntypedStateMachine fsm = builder.newStateMachine(FSMState.A);
fsm.fire(FSMEvent.ToB, 10);
UI.logv("Current state is " + fsm.getCurrentState());
fsm.fire(FSMEvent.ToC, 4);
UI.logv("Current state is " + fsm.getCurrentState());
}
示例2: startRegistrationFsm
import org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder; //導入依賴的package包/類
private void startRegistrationFsm()
{
RCLogger.i(TAG, "startRegistrationFsm()");
// Build state transitions
UntypedStateMachineBuilder fsmBuilder = StateMachineBuilderFactory.create(RegistrationFsm.class, RegistrationFsm.RCDeviceFSMListener.class);
// Seems 'fromAny' doesn't work as expected, so sadly we need to add more states. Let's leave this around though in case we can improve in the future
//fsmBuilder.transit().fromAny().to(RegistrationFsm.FSMState.signalingReadyState).on(RegistrationFsm.FSMEvent.signalingInitializationRegistrationEvent).callMethod("toSignalingInitializationReady");
//fsmBuilder.transit().fromAny().to(RegistrationFsm.FSMState.pushReadyState).on(RegistrationFsm.FSMEvent.pushInitializationRegistrationEvent).callMethod("toPushInitializationReady");
// Set up the state transitions of the FSM and associate methods to handle them
// transitions to signaling ready, either during initialization or reconfiguration
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.signalingReadyState)
.on(RegistrationFsm.FSMEvent.signalingInitializationRegistrationEvent).callMethod("toSignalingInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.pushReadyState).to(RegistrationFsm.FSMState.signalingReadyState)
.on(RegistrationFsm.FSMEvent.signalingInitializationRegistrationEvent).callMethod("toSignalingInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.signalingReadyState)
.on(RegistrationFsm.FSMEvent.signalingReconfigureRegistrationEvent).callMethod("toSignalingReconfigurationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.pushReadyState).to(RegistrationFsm.FSMState.signalingReadyState)
.on(RegistrationFsm.FSMEvent.signalingReconfigureRegistrationEvent).callMethod("toSignalingReconfigurationReady");
// transitions to push ready when push configuration really happens asynchronously,
// either during initialization or reconfiguration
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushInitializationRegistrationEvent).callMethod("toPushInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.signalingReadyState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushInitializationRegistrationEvent).callMethod("toPushInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushReconfigureRegistrationEvent).callMethod("toPushReconfigurationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.signalingReadyState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushReconfigureRegistrationEvent).callMethod("toPushReconfigurationReady");
// transitions to push ready when push configuration is not necessary because server already up to date,
// either during initialization or reconfiguration
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushInitializationRegistrationNotNeededEvent).callMethod("toPushInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.signalingReadyState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushInitializationRegistrationNotNeededEvent).callMethod("toPushInitializationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.initialState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushReconfigureRegistrationNotNeededEvent).callMethod("toPushReconfigurationReady");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.signalingReadyState).to(RegistrationFsm.FSMState.pushReadyState)
.on(RegistrationFsm.FSMEvent.pushReconfigureRegistrationNotNeededEvent).callMethod("toPushReconfigurationReady");
// transitions back to initial state
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.signalingReadyState).to(RegistrationFsm.FSMState.initialState)
.on(RegistrationFsm.FSMEvent.resetStateMachine).callMethod("toInitialState");
fsmBuilder.externalTransition().from(RegistrationFsm.FSMState.pushReadyState).to(RegistrationFsm.FSMState.initialState)
.on(RegistrationFsm.FSMEvent.resetStateMachine).callMethod("toInitialState");
HashMap<String, String> map = new HashMap<>();
// notice the extraParams argument is passed to the RegistrationFsm constructor
registrationFsm = fsmBuilder.newStateMachine(RegistrationFsm.FSMState.initialState, this);
/*
registrationFsm.addStateMachineListener(new StateMachine.StateMachineListener<UntypedStateMachine, Object, Object, Object>() {
@Override
public void stateMachineEvent(StateMachine.StateMachineEvent<UntypedStateMachine, Object, Object, Object> event)
{
RCLogger.i(TAG, "stateMachineEvent():" + event);
}
});
*/
}