/** * @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"); }
/** * Construct a constant source with the given container and name. Create the <i>value</i> * parameter, initialize its value to the default value of an IntToken with value 1. * * @param container The container. * @param name The name of this actor. * @exception IllegalActionException If the entity cannot be contained by the proposed container. * @exception NameDuplicationException If the container already has an actor with this name. */ public Counter(CompositeEntity container, String name) throws NameDuplicationException, IllegalActionException { super(container, name); startValueParam = new Parameter(this, "start", new LongToken(1)); startValueParam.setTypeEquals(BaseType.LONG); registerConfigurableParameter(startValueParam); reset = PortFactory.getInstance().createInputPort(this, "reset", null); }
/** Create the second port needed by modulo function */ private void _createSecondPort() throws NameDuplicationException, IllegalActionException { // Go looking for the port in case somebody else created the port // already. For example, this might // happen in shallow code generation. secondOperand = (Port) getPort("secondOperand"); if (secondOperand == null) { secondOperand = PortFactory.getInstance().createInputPort(this, "secondOperand", Double.class); } else if (secondOperand.getContainer() == null) { secondOperand.setContainer(this); } }