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; }
//----------------------------------------------------------- // Member functions. // // Constructor. public StateChangeEventArgs(string fsmName, string transitionType, State previousState, State newState) { _fsmName = fsmName; _transitionType = transitionType; _previousState = previousState; _newState = newState; }
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; }
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; }
public void ClearState() { previousState_ = state_; state_ = null; return; }
//----------------------------------------------------------- // 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; }
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; }