예제 #1
0
        public void SetState(State state)
        {
            StateChangeEventArgs e =
                new StateChangeEventArgs(
                    name_, "SET", state_, state);

            #if TRACE
            Trace.WriteLine("ENTER STATE     : " +    state.Name);
            #endif

            state_ = state;

            OnStateChange(e);

            return;
        }
예제 #2
0
 //-----------------------------------------------------------
 // Member functions.
 //
 // Constructor.
 public StateChangeEventArgs(string fsmName,
                             string transitionType,
                             State previousState,
                             State newState)
 {
     _fsmName = fsmName;
     _transitionType = transitionType;
     _previousState = previousState;
     _newState = newState;
 }
예제 #3
0
        public void PushState(State state)
        {
            StateChangeEventArgs e =
                new StateChangeEventArgs(
                    name_, "PUSH", state_, state);

            #if TRACE
            Trace.WriteLine("PUSH TO STATE   : " +    state.Name);
            #endif

            if (state_ != null)
            {

                stateStack_.Push(state_);
            }

            state_ = state;

            OnStateChange(e);

            return;
        }
예제 #4
0
        public void PopState()
        {
            if (stateStack_.Count == 0)
            {
            #if TRACE
                Trace.WriteLine("POPPING ON EMPTY STATE STACK.");
            #endif

                throw new
                    System.InvalidOperationException(
                        "popping an empty state stack");
            }
            else
            {
                State nextState = (State) stateStack_.Pop();
                StateChangeEventArgs e =
                    new StateChangeEventArgs(
                        name_, "POP", state_, nextState);

                // The pop method removes the top element
                // from the stack and returns it.
                state_ = nextState;

            #if TRACE
                Trace.WriteLine("POP TO STATE    : " + state_.Name);
            #endif

                OnStateChange(e);
            }

            return;
        }
예제 #5
0
        public void ClearState()
        {
            previousState_ = state_;
            state_ = null;

            return;
        }
예제 #6
0
 //-----------------------------------------------------------
 // Member functions.
 //
 public FSMContext(State state)
 {
     // There is no state until the application explicitly
     // sets the initial state.
     name_ = "FSMContext";
     state_ = state;
     transition_ = "";
     previousState_ = null;
     stateStack_ = new System.Collections.Stack();
     debugFlag_ = false;
     debugStream_ = null;
 }
예제 #7
0
        public void SetState(State state)
        {
            StateChangeEventArgs e =
                new StateChangeEventArgs(
                    name_, "SET", state_, state);

            #if TRACE
            Trace.WriteLine("ENTER STATE     : " +    state.Name);
            #endif

            // clearState() is not called when a transition has
            // no actions, so set _previousState to _state in
            // that situation. We know clearState() was not
            // called when _state is not null.
            if (state_ != null)
            {
                previousState_ = state_;
            }

            state_ = state;

            OnStateChange(e);

            return;
        }