Пример #1
0
 /**
  * An actor is a quasi-static actor if 1) it has a tree-structured FSM. 2) all feedback
  * transitions return back to the initial state. 3) a state does not terminate.
  *
  * @return
  */
 private boolean isQuasiStaticActor() {
   ActorSchedule schedule = mActor.getImplementation().getSchedule();
   State initialState = schedule.getInitialState();
   for (Transition transition : initialState.getTransitions()) {
     State dstState = transition.getTargetState();
     List<State> visitedStates = new ArrayList<State>();
     visitedStates.add(dstState);
     if (!isQuasiStaticBranch(initialState, dstState, visitedStates)) return false;
   }
   return true;
 }
Пример #2
0
 /**
  * Checks if the guards of those non-deterministic actions matches the following format. Guards
  * are of the form <M "op" C [ (and/or) M "op" C]> where M is a port variable, "op" is "=, !=, <=,
  * >=, <, >" and C is a constant.
  */
 public boolean areNonDeterministicStatesSimplyGuarded() {
   ActorSchedule schedule = mActor.getImplementation().getSchedule();
   for (State state : schedule.getStates()) {
     if (state.getTransitions().size() > 1) {
       for (Transition transition : state.getTransitions()) {
         Action action = transition.getAction();
         if (!action.hasGuard()) return false;
         Guard guard = action.getGuard();
         Map<InputLookAhead, UnionOfDisjointIntervals> modeSet = guard.matchScenarioAwareGuard();
         if (modeSet == null) return false;
       }
     }
   }
   return true;
 }
Пример #3
0
  private boolean isQuasiStaticBranch(State initialState, State state, List<State> visitedStates) {
    // Trivial case is a one-state FSM.
    if (state == initialState) return true;

    // Check if state does not terminate.
    // This should actually check if the guards of the actions
    // of a state fully cover the test space.
    if (getPotentiallyTerminalStates().contains(state)) return false;

    // Check for tree-like topology.
    for (Transition transition : state.getTransitions()) {
      State dstState = transition.getTargetState();
      if (dstState == initialState) {
        continue;
      } else if (visitedStates.contains(dstState)) {
        return false;
      } else {
        List<State> newBranch = new ArrayList<State>(visitedStates);
        newBranch.add(dstState);
        if (!isQuasiStaticBranch(initialState, dstState, newBranch)) return false;
      }
    }
    return true;
  }