// Building the turnstile transition table
        public Turnstile(ITurnstileController controller)
        {
            Action unlock     = new Action(controller.Unlock);
            Action alarm      = new Action(controller.Alarm);
            Action thankYou   = new Action(controller.Thankyou);
            Action lockAction = new Action(controller.Lock);

            AddTransition(State.LOCKED, Event.COIN, State.UNLOCKED, unlock);
            AddTransition(State.LOCKED, Event.PASS, State.LOCKED, alarm);
            AddTransition(State.UNLOCKED, Event.COIN, State.UNLOCKED, thankYou);
            AddTransition(State.UNLOCKED, Event.PASS, State.LOCKED, lockAction);
        }
Пример #2
0
        public Turnstile(ITurnstileController controller)
        {
            // 构建状态迁移表
            Action unlock      = controller.Unlock;
            Action alarm       = controller.Alarm;
            Action thankyou    = controller.Thankyou;
            Action lock_action = controller.Lock;

            AddTransition(eTurnstileState.Locked, eTurnstileState.Unlocked, eTurnstileEvent.Coin, unlock);
            AddTransition(eTurnstileState.Locked, eTurnstileState.Locked, eTurnstileEvent.Pass, alarm);
            AddTransition(eTurnstileState.Unlocked, eTurnstileState.Unlocked, eTurnstileEvent.Coin, thankyou);
            AddTransition(eTurnstileState.Unlocked, eTurnstileState.Locked, eTurnstileEvent.Pass, lock_action);

            State = eTurnstileState.Locked;
        }
 public Turnstile(ITurnstileController action)
 {
     turnstileController = action;
 }
 public TurnstileFSM(ITurnstileController controller)
 {
     this.controller = controller;
 }