本文整理汇总了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);
}
});
*/
}