當前位置: 首頁>>代碼示例>>Java>>正文


Java UntypedStateMachineBuilder.newStateMachine方法代碼示例

本文整理匯總了Java中org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder.newStateMachine方法的典型用法代碼示例。如果您正苦於以下問題:Java UntypedStateMachineBuilder.newStateMachine方法的具體用法?Java UntypedStateMachineBuilder.newStateMachine怎麽用?Java UntypedStateMachineBuilder.newStateMachine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.squirrelframework.foundation.fsm.UntypedStateMachineBuilder的用法示例。


在下文中一共展示了UntypedStateMachineBuilder.newStateMachine方法的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.newStateMachine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。