Exemplo n.º 1
0
  /**
   * Generate code for all the actors associated with the given FSMDirector.
   *
   * @return String containing the actor code.
   * @exception IllegalActionException If throw while accessing the model.
   */
  private String _generateActorCode() throws IllegalActionException {
    StringBuffer code = new StringBuffer();
    ptolemy.domains.fsm.kernel.FSMDirector director =
        (ptolemy.domains.fsm.kernel.FSMDirector) getComponent();
    ptolemy.domains.fsm.kernel.FSMActor controller = director.getController();
    // int depth = 1;

    // Iterator states = controller.entityList().iterator();
    Iterator states = controller.deepEntityList().iterator();
    // int stateCount = 0;
    // depth++;

    while (states.hasNext()) {
      // code.append(_getIndentPrefix(depth));
      // code.append("case " + stateCount + ":" + _eol);
      // stateCount++;

      // depth++;

      State state = (State) states.next();
      Actor[] actors = state.getRefinement();
      Set<Actor> actorsSet = new HashSet();
      ;
      if (actors != null) {
        for (int i = 0; i < actors.length; i++) {
          actorsSet.add(actors[i]);
        }
      }

      if (actors != null) {
        // for (int i = 0; i < actors.length; i++) {
        Iterator actorIterator = actorsSet.iterator();
        Actor actors2;
        while (actorIterator.hasNext()) {
          actors2 = (Actor) actorIterator.next();
          CodeGeneratorHelper actorHelper = (CodeGeneratorHelper) _getHelper((NamedObj) actors2);
          if (actors2.getDirector().getFullName().contains("Giotto") == false) {
            // code.append("void "+_getActorName(actors2)+"(){");
            code.append(
                actorHelper
                    .generateFireFunctionCode()); // this was there initially and it works with SDF
            code.append(actorHelper.generateTypeConvertFireCode());
            // code.append(_eol+"}"+_eol);
          } else {
            code.append(_eol + "//modal model contains giotto director" + _eol);
          }
        }
      }
    }

    return code.toString();
  }
Exemplo n.º 2
0
  /**
   * Return the worst case execution time (WCET) seen by this director.
   *
   * @return The Worst Case Execution Time (WCET).
   * @exception IllegalActionException If there is a problem determining the WCET or a problem
   *     accessing the model.
   */
  public double getWCET() throws IllegalActionException {
    ptolemy.domains.fsm.kernel.FSMDirector director =
        (ptolemy.domains.fsm.kernel.FSMDirector) getComponent();
    ptolemy.domains.fsm.kernel.FSMActor controller = director.getController();
    // int depth = 1;

    Iterator states = controller.deepEntityList().iterator();
    // int stateCount = 0;
    // depth++;
    double largestWCET = 0.0;

    while (states.hasNext()) {

      // stateCount++;

      // depth++;

      State state = (State) states.next();
      Actor[] actors = state.getRefinement();
      Set<Actor> actorsSet = new HashSet();
      ;
      if (actors != null) {
        for (int i = 0; i < actors.length; i++) {
          actorsSet.add(actors[i]);
        }
      }
      for (Actor actor : actorsSet) {
        ptolemy.codegen.actor.Director df = new ptolemy.codegen.actor.Director(actor.getDirector());
        double localWCET = df.getWCET();
        if (localWCET > largestWCET) {
          largestWCET = localWCET;
        }
      }
    }
    if (_debugging) {
      _debug("fsm director has wcet of " + largestWCET);
    }
    return largestWCET;
  }