예제 #1
0
    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);
        }
    }
예제 #2
0
 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);
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
 public TFSMMachine setDefaultState(TFSMWorkingData wData, string id)
 {        
     if (_states.ContainsKey(id))
     {
         wData._defaultState = _states[id];
     }
     else {
         TLogger.WARNING("no state found");
     }
     return this;
 }
예제 #5
0
 public TFSMMachine setDefaultState(TFSMWorkingData wData, string id)
 {
     if (_states.ContainsKey(id))
     {
         wData._defaultState = _states[id];
     }
     else
     {
         TLogger.WARNING("no state found");
     }
     return(this);
 }
예제 #6
0
 protected virtual void onEnter(TFSMWorkingData wData)
 {
 }
예제 #7
0
 internal void exit(TFSMWorkingData wData)
 {
     onExit(wData);
 }
예제 #8
0
 internal void execute(TFSMWorkingData wData)
 {
     onExecute(wData);
 }
예제 #9
0
 internal void enter(TFSMWorkingData wData)
 {
     onEnter(wData);
 }
예제 #10
0
 protected virtual void onExit(TFSMWorkingData wData) { }
예제 #11
0
 protected virtual void onExecute(TFSMWorkingData wData) { }
예제 #12
0
 internal void exit(TFSMWorkingData wData)
 {
     onExit(wData);
 }
예제 #13
0
 internal void execute(TFSMWorkingData wData)
 {
     onExecute(wData);
 }
예제 #14
0
 internal void enter(TFSMWorkingData wData)
 {
     onEnter(wData);
 }
예제 #15
0
 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;
 }
예제 #16
0
 protected virtual void onExecute(TFSMWorkingData wData)
 {
 }
예제 #17
0
 protected virtual void onExit(TFSMWorkingData wData)
 {
 }
예제 #18
0
 protected virtual void onEnter(TFSMWorkingData wData) { }