public PortAnalysis getPortAnalysis(String name) {
   PortInstance portInstance = null;
   for (PortInstance p : mActor.getPorts()) {
     if (p.getName().equals(name)) {
       portInstance = p;
       break;
     }
   }
   if (portInstance != null) {
     assert (mPortMap.get(portInstance) != null);
     return mPortMap.get(portInstance);
   }
   return null;
 }
 public List<Integer> getAnnotatedPortRate(PortInstance p) {
   List<Integer> portRate = new ArrayList<Integer>();
   for (AnnotatedActionProperty aap : annotatedActionProperties) {
     portRate.add(aap.portRates.get(p.getName()));
   }
   return portRate;
 }
  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;
    }
  }