示例#1
0
        private Boolean SetNextState(CSIState newState)
        {
            bool success = false;

            if (newState != null)
            {
                CSIState _previousState = _currentState;

                // Old state gets notified it is changing out.
                if (_previousState != null)
                {
                    //AppI_Debug.ShowMsg("setNextState Old:" + _previousState.ToString());
                    _previousState.Exit();
                }

                //AppI_Debug.ShowMsg("setNextState Current: " + newState.ToString());

                _currentState = newState;
                _nextState    = null;

                if (_currentState != null)
                {
                    //Note the time at which we entered this state.
                    _enteredStateTime = TimeHelp.GetCurrentMS();
                    _currentState.Enter(this);
                    success = true;
                }
            }
            else
            {
                AppI_Debug.ShowMsg("setNextState: ERROR:NULL STATE!");
                success = false;
            }
            return(success);
        }
示例#2
0
        public string GetStateName(CSIState state)
        {
            foreach (KeyValuePair <string, CSIState> dictEntry in machineStates)
            {
                if (dictEntry.Value == state)
                {
                    return(dictEntry.Key);
                }
            }

            return(null);
        }
示例#3
0
        public CSIState GetState(string name)
        {
            //handlers when the states returned here trying to be accessed are null
            if (machineStates.ContainsKey(name))
            {
                CSIState retState = machineStates[name] as CSIState;
                if (retState == null)
                {
                    //error condition
                    AppI_Debug.ShowMsg("getState: " + name + " ERROR: NULL!");
                    return(null);
                }
                return(retState);
            }

            //error condition
            AppI_Debug.ShowMsg("getState: " + name + " ERROR:NOT FOUND!");
            return(null);
        }
示例#4
0
 //custom machine calls
 public void AddState(string name, CSIState state)
 {
     machineStates[name] = state;
 }
示例#5
0
        public Boolean SetNextStateNamed(string name)
        {
            CSIState newState = GetState(name);

            return(SetNextState(newState));
        }