public void process(TFSMWorkingData wData) { if (wData._isFirstUpdate) { wData._currentState = wData._defaultState; if (wData._currentState != null) { wData._currentState.enter(wData); wData._isFirstUpdate = false; } } TFSMState newState = wData._currentState; if (wData._stimulus != null) { newState = wData._stimulus.getGoalState(); wData._stimulus = null; } if (newState != wData._currentState) { if (wData._currentState != null) { wData._currentState.exit(wData); } wData._currentState = newState; if (wData._currentState != null) { wData._currentState.enter(wData); } } if (wData._currentState != null) { wData._currentState.execute(wData); } }
public bool signal(TFSMSignal s, TFSMWorkingData wData) { if (wData._currentState != null) { string id = TFSMLink.LINK_NAME_GENERATOR(wData._currentState.name, s.targetState); TFSMLink link; if (!_stateLinks.TryGetValue(id, out link)) { TLogger.WARNING("no link found."); return(false); } if (link.getStartState() != wData._currentState) { TLogger.WARNING("connot use this link for current state:" + wData._currentState.name + ":" + id); return(false); } wData._stimulus = link; } else { if (wData._isFirstUpdate == false) { setDefaultState(wData, s.targetState); } else { TLogger.WARNING("state fatal error:" + s.targetState); return(false); } } return(true); }
public TFSMMachine setDefaultState(TFSMWorkingData wData, string id) { if (_states.ContainsKey(id)) { wData._defaultState = _states[id]; } else { TLogger.WARNING("no state found"); } return this; }
public TFSMMachine setDefaultState(TFSMWorkingData wData, string id) { if (_states.ContainsKey(id)) { wData._defaultState = _states[id]; } else { TLogger.WARNING("no state found"); } return(this); }
protected virtual void onEnter(TFSMWorkingData wData) { }
internal void exit(TFSMWorkingData wData) { onExit(wData); }
internal void execute(TFSMWorkingData wData) { onExecute(wData); }
internal void enter(TFSMWorkingData wData) { onEnter(wData); }
protected virtual void onExit(TFSMWorkingData wData) { }
protected virtual void onExecute(TFSMWorkingData wData) { }
public bool signal(TFSMSignal s, TFSMWorkingData wData) { if (wData._currentState != null) { string id = TFSMLink.LINK_NAME_GENERATOR(wData._currentState.name, s.targetState); TFSMLink link; if (!_stateLinks.TryGetValue(id, out link)) { TLogger.WARNING("no link found."); return false; } if (link.getStartState() != wData._currentState) { TLogger.WARNING("connot use this link for current state:" + wData._currentState.name + ":" + id); return false; } wData._stimulus = link; } else { if (wData._isFirstUpdate == false) { setDefaultState(wData, s.targetState); } else { TLogger.WARNING("state fatal error:" + s.targetState); return false; } } return true; }