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); }
public string GetStateName(CSIState state) { foreach (KeyValuePair <string, CSIState> dictEntry in machineStates) { if (dictEntry.Value == state) { return(dictEntry.Key); } } return(null); }
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); }
//custom machine calls public void AddState(string name, CSIState state) { machineStates[name] = state; }
public Boolean SetNextStateNamed(string name) { CSIState newState = GetState(name); return(SetNextState(newState)); }