public boolean isSingleRateActor() {
   for (Action action : mActor.getImplementation().getActions()) {
     PortSignature portSignature = action.getPortSignature();
     for (PortInstance portInstance : portSignature.getPorts()) {
       if (portSignature.getPortRate(portInstance) > 1) return false;
     }
   }
   return true; // executesIndefinitely();
 }
 public boolean areAllActionsGuarded() {
   for (Action action : mActor.getImplementation().getActions()) {
     ActionAnalysis actionAnalysis = new ActionAnalysis(action, mActor);
     if (!action.hasGuard() && !actionAnalysis.isCatchAll()) {
       return false;
     }
   }
   return true;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
  public GenericActorAnalysis(ActorInstance actor, ActorAnalysis delegate) {
    mActor = actor;
    actorAnalysis = delegate;
    mActorType = ActorInstanceType.UNCLASSIFIED;

    stateSize = new Integer(0);
    executionTime = new Integer(0);
    for (PortInstance portInstance : mActor.getPorts()) {
      PortAnalysis portAnalysis = new PortAnalysis(portInstance);
      mPortMap.put(portInstance, portAnalysis);
    }

    if (actorAnalysis != null) {
      for (Action action : actor.getImplementation().getActions()) {
        ActionAnalysis actionAnalysis = new ActionAnalysis(action, actor);
        mActionMap.put(action, actionAnalysis);
      }
    }

    // Parse annotations
    if (mActor.hasAnnotation("ActorProperty")) {
      // Set execution time
      String time = mActor.getAnnotationArgumentValue("ActorProperty", "WCET");
      if (time != null) executionTime = new Integer(time);

      // Set state size
      String size = mActor.getAnnotationArgumentValue("ActorProperty", "StateSize");
      if (size != null) stateSize = new Integer(size);

      // Set actor instance type
      String type = mActor.getAnnotationArgumentValue("ActorProperty", "Type");
      if (type != null) {
        typeAnnotated = true;
        if (type.equalsIgnoreCase("HSDF")) {
          mActorType = ActorInstanceType.SINGLE_RATE_STATIC;
        } else if (type.equalsIgnoreCase("SDF")) {
          mActorType = ActorInstanceType.MULTI_RATE_STATIC;
        } else if (type.equalsIgnoreCase("CSDF")) {
          mActorType = ActorInstanceType.CYCLO_STATIC;
        } else typeAnnotated = false;
      }

      // Set action execution times
      try {
        String actionProperties =
            mActor.getAnnotationArgumentValue("ActorProperty", "ActionProperty");
        if (typeAnnotated && actionProperties == null)
          throw new NullPointerException(
              "ActionProperty tag must exist " + "if actor type is annotated with HSDF/SDF/CSDF.");

        if (typeAnnotated && actionProperties != null) {
          for (String actionProperty : actionProperties.split(";")) {
            String actionPropertyPair[] = actionProperty.split(":");
            if (actionPropertyPair.length != 2)
              throw new Exception(
                  "ActionProperty tag syntax error. "
                      + "Use Eg. ActionProperty=\"action1:WCET=2, p1=1, p2=3;action2:WCET=1, p1=0, p2=4\"");
            AnnotatedActionProperty aap = new AnnotatedActionProperty(actionPropertyPair[0]);
            for (String property : actionPropertyPair[1].split(",")) {
              String propertyPair[] = property.split("=");
              if (propertyPair[0].equalsIgnoreCase("WCET"))
                aap.executionTime = new Integer(propertyPair[1]);
              else aap.portRates.put(propertyPair[0], new Integer(propertyPair[1]));
            }
            annotatedActionProperties.add(aap);
          }
          // Check if all ports have a rate in all ActionProperties
          for (AnnotatedActionProperty aap : annotatedActionProperties) {
            for (PortInstance p : getActor().getPorts()) {
              if (aap.portRates.get(p.getName()) == null)
                throw new Exception(
                    "Type annotated actor '"
                        + p.getActor().getInstanceName()
                        + "' does not have rate for port '"
                        + p.getName()
                        + "'.");
            }
          }
        }
      } catch (Exception e) {
        System.out.println(e.getMessage());
        System.exit(1);
      }
    }

    if (!typeAnnotated && actorAnalysis != null) {
      if (isSingleRateStaticActor()) mActorType = ActorInstanceType.SINGLE_RATE_STATIC;
      else if (isMultiRateStaticActor()) mActorType = ActorInstanceType.MULTI_RATE_STATIC;
      else if (isCycloStaticActor()) mActorType = ActorInstanceType.CYCLO_STATIC;
      else if (isQuasiStaticActor()) mActorType = ActorInstanceType.QUASI_STATIC;
      else if (isDynamicActor()) mActorType = ActorInstanceType.DYNAMIC;
    }
  }