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 addLink(string idFrom, string idTo) { string id = TFSMLink.LINK_NAME_GENERATOR(idFrom, idTo); if (_stateLinks.ContainsKey(id)) { TLogger.WARNING("name conflict for this state: " + id); return(this); } TFSMState fromState, toState; bool hasFromState = _states.TryGetValue(idFrom, out fromState); bool hasToState = _states.TryGetValue(idTo, out toState); if (hasFromState || hasToState) { TLogger.WARNING("state not found: " + idFrom + " and " + idTo); return(this); } _stateLinks.Add(id, new TFSMLink(fromState, toState)); return(this); }