当前位置: 首页>>代码示例>>Java>>正文


Java UntypedStateMachineBuilder类代码示例

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

	}
 
开发者ID:y12studio,项目名称:bkbc-bitcoinpos,代码行数:24,代码来源:BitcoinPosActivity.java

示例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);
         }
      });
*/
   }
 
开发者ID:RestComm,项目名称:restcomm-android-sdk,代码行数:71,代码来源:RCDevice.java


注:本文中的org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。