Beispiel #1
0
  /**
   * Generate the preinitialize code. Declare temporary variables.
   *
   * @return The preinitialize code.
   * @exception IllegalActionException If the code stream encounters an error in processing the
   *     specified code block(s).
   */
  public String generatePreinitializeCode() throws IllegalActionException {
    // Automatically append the "preinitBlock" by default.
    super.generatePreinitializeCode();

    ptolemy.actor.lib.NonStrictTest actor = (ptolemy.actor.lib.NonStrictTest) getComponent();

    if (actor.input.getWidth() > 1) {
      ArrayList args = new ArrayList();
      args.add(Integer.valueOf(0));
      for (int i = 0; i < actor.input.getWidth(); i++) {
        args.set(0, Integer.valueOf(i));
        _codeStream.appendCodeBlock("TokenPreinitBlock", args);
      }
    }

    for (int i = 0; i < actor.input.getWidth(); i++) {
      if (!isPrimitive(actor.input.getType())) {
        // One of the channels is not primitive, so we will
        // later call TokenBlock($channel), so we define
        // toleranceToken for our use.
        _codeStream.appendCodeBlock("toleranceTokenPreinitBlock");
        break;
      }
    }

    return processCode(_codeStream.toString());
  }