Esempio n. 1
0
  /**
   * @param container
   * @param name
   * @throws ptolemy.kernel.util.NameDuplicationException
   * @throws ptolemy.kernel.util.IllegalActionException
   */
  public MathFunction(final CompositeEntity container, final String name)
      throws NameDuplicationException, IllegalActionException {
    super(container, name);
    // Parameters
    function = new StringParameter(this, "function");
    function.setExpression("exp");
    function.addChoice("exp");
    function.addChoice("log");
    function.addChoice("modulo");
    function.addChoice("sign");
    function.addChoice("square");
    function.addChoice("sqrt");
    _function = _EXP;

    // Ports
    // secondOperand port is not allocated in the constructor
    // instead it will allocated dynamically during run-time

    firstOperand = PortFactory.getInstance().createInputPort(this, "input", Double.class);
    output = PortFactory.getInstance().createOutputPort(this, "output");

    _attachText(
        "_iconDescription",
        "<svg>\n"
            + "<rect x=\"-30\" y=\"-15\" "
            + "width=\"60\" height=\"30\" "
            + "style=\"fill:white\"/>\n"
            + "</svg>\n");
  }
Esempio n. 2
0
  /**
   * this function instantiate all the parameter necessary to display an advanced submission form
   * for the current selected opal service
   */
  private void _createSubmission(AppMetadata app) throws IllegalActionException {
    _emptyParamtersArray();
    log.info("Creating complex submission form. For service URL: " + app.getURL());
    try {
      Group[] group = app.getGroups();
      ArrayList tempParam = new ArrayList();
      if (group != null) {
        for (int i = 0; i < group.length; i++) {
          // first the parameters
          ArgParam[] argParams = group[i].getArgParams();
          if (argParams != null) {
            for (int paramCount = 0; paramCount < argParams.length; paramCount++) {
              if (argParams[paramCount].getType().equals("FILE")
                  && argParams[paramCount].getIoType().equals("INPUT")) {
                // This is an input file box
                FilePortParameter param =
                    new FilePortParameter(this, argParams[paramCount].getId());
                if (argParams[paramCount].getSelectedValue() != null)
                  // setting the default value
                  param.setExpression(argParams[paramCount].getSelectedValue());
                tempParam.add(param);
              } else if (argParams[paramCount].getValues() != null) {
                String[] choices = argParams[paramCount].getValues();
                // this is a multiple choices
                StringParameter param = new StringParameter(this, argParams[paramCount].getId());
                for (int z = 0; z < choices.length; z++) param.addChoice(choices[z]);
                if (argParams[paramCount].getSelectedValue() != null)
                  // setting the default value
                  param.setExpression(argParams[paramCount].getSelectedValue());
                tempParam.add(param);
              } else {
                // this is a string
                StringParameter param = new StringParameter(this, argParams[paramCount].getId());
                if (argParams[paramCount].getSelectedValue() != null)
                  // setting the default value
                  param.setExpression(argParams[paramCount].getSelectedValue());
                tempParam.add(param);
              } // else
            } // for argParam
          } // argParams
          // and then the flags
          ArgFlag[] argFlags = group[i].getArgFlags();
          if (argFlags != null) {
            for (int paramCount = 0; paramCount < argFlags.length; paramCount++) {
              Parameter check = null;
              if (argFlags[paramCount].isSelected())
                check = new Parameter(this, argFlags[paramCount].getId(), BooleanToken.TRUE);
              else check = new Parameter(this, argFlags[paramCount].getId(), BooleanToken.FALSE);
              check.setTypeEquals(BaseType.BOOLEAN);
              tempParam.add(check);
            }
          } // argFlags
        }
      } // group
      // set the numberFiles to 0
      StringParameter param = (StringParameter) this.getAttribute("numberFiles");
      if (param != null) param.setToken(new StringToken("0"));

      // not needed anymore delete the tempParam
      // _interfaceParameters = (Parameter []) tempParam.toArray(new
      // Parameter[tempParam.size()]);
    } catch (NameDuplicationException e) {
      log.error("The parameter could not be instantiated. Error message: " + e.getMessage());
      throw new IllegalActionException(
          this, "The complex submission form could not be initialized: " + e.getMessage());
    }
    return;
  }