Examples of TypedIOPort


Examples of ptolemy.actor.TypedIOPort

        super.preinitialize();

        Iterator ports = outputPortList().iterator();

        while (ports.hasNext()) {
            TypedIOPort port = (TypedIOPort) ports.next();

            // Ensure that the production rate is one.
            // FIXME: This may not be right if there is no
            // actual source of data for this port (e.g. no
            // SetVariable actor).
            Variable rate = (Variable) port.getAttribute("tokenProductionRate");

            if (rate == null) {
                try {
                    rate = new Variable(port, "tokenProductionRate");
                } catch (NameDuplicationException e) {
                    throw new InternalErrorException(e);
                }
            }

            rate.setToken(new IntToken(1));

            String portName = port.getName();
            Attribute attribute = getAttribute(portName);

            if (attribute == null) {
                try {
                    workspace().getWriteAccess();
                    attribute = new Variable(this, portName);
                } catch (NameDuplicationException ex) {
                    throw new InternalErrorException(ex);
                } finally {
                    workspace().doneWriting();
                }
            }

            // attribute is now assured to be non-null.
            if (attribute instanceof Variable) {
                port.setTypeAtLeast((Variable) attribute);
            } else {
                // Assume the port type must be a string.
                port.setTypeEquals(BaseType.STRING);
            }
        }
    }
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

    public EventSource(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);

        // Create port and parameters.
        output = new TypedIOPort(this, "output", false, true);
        new Parameter(output, "signalType", new StringToken("DISCRETE"));

        period = new Parameter(this, "period");
        period.setExpression("2.0");
        period.setTypeEquals(BaseType.DOUBLE);
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

    public DatagramReader(CompositeEntity container, String name)
            throws NameDuplicationException, IllegalActionException {
        super(container, name);

        // ports - Ordering here sets the order they show up in Vergil
        returnAddress = new TypedIOPort(this, "returnAddress");
        returnAddress.setTypeEquals(BaseType.STRING);
        returnAddress.setOutput(true);

        returnSocketNumber = new TypedIOPort(this, "returnSocketNumber");
        returnSocketNumber.setTypeEquals(BaseType.INT);
        returnSocketNumber.setOutput(true);

        output = new TypedIOPort(this, "output");
        output.setTypeEquals(new ArrayType(BaseType.UNSIGNED_BYTE));
        output.setOutput(true);

        trigger = new TypedIOPort(this, "trigger", true, false);
        trigger.setTypeEquals(BaseType.GENERAL);
        trigger.setMultiport(true);

        // parameters - Ordering here sets the order they show up in Vergil
        localSocketNumber = new Parameter(this, "localSocketNumber");
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

     *   actor with this name.
     */
    public BusAssembler(CompositeEntity container, String name)
            throws NameDuplicationException, IllegalActionException {
        super(container, name);
        output = new TypedIOPort(this, "output", false, true);
        output.setMultiport(true);
        _attachText("_iconDescription", "<svg>\n"
                + "<rect x=\"0\" y=\"0\" width=\"6\" "
                + "height=\"40\" style=\"fill:black\"/>\n" + "</svg>\n");
    }
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

     throws it.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        Iterator inputPorts = inputPortList().iterator();
        TypedIOPort inputPort = (TypedIOPort) (inputPorts.hasNext() ? inputPorts
                .next()
                : null);
        int inputWidth = (inputPort != null) ? inputPort.getWidth() : 0;
        int i = 0;
        int j = 0;

        while (inputPort != null) {
            if ((i < inputWidth) && inputPort.hasToken(i)) {
                Token t = inputPort.get(i);

                if (j < _outputWidth) {
                    output.send(j, t);
                }
            }

            j++;

            if (++i >= inputWidth) {
                inputPort = (TypedIOPort) (inputPorts.hasNext() ? inputPorts
                        .next() : null);
                inputWidth = (inputPort != null) ? inputPort.getWidth() : 0;
                i = 0;
            }
        }
    }
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

        TypedIORelation outputRelation = (TypedIORelation) outputRelations
                .get(0);
        Iterator inputPorts = inputPortList().iterator();

        while (inputPorts.hasNext()) {
            TypedIOPort port = (TypedIOPort) inputPorts.next();
            _outputWidth += port.getWidth(); // includes all linked relations
        }

        outputRelation.setWidth(_outputWidth);

        // TODO: figure out how to obey if the output relation width is
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

     *   an entity already in the container.
     */
    public FirstOrderHold(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        derivative = new TypedIOPort(this, "derivative", true, false);
        defaultValue = new Parameter(this, "defaultValue");
        defaultValue.setExpression("0.0");
        defaultDerivative = new Parameter(this, "defaultDerivative");
        defaultDerivative.setExpression("0.0");

View Full Code Here

Examples of ptolemy.actor.TypedIOPort

     *   actor with this name.
     */
    public BusDisassembler(CompositeEntity container, String name)
            throws NameDuplicationException, IllegalActionException {
        super(container, name);
        input = new TypedIOPort(this, "input", true, false);
        input.setMultiport(true);
        _attachText("_iconDescription", "<svg>\n"
                + "<rect x=\"0\" y=\"0\" width=\"6\" "
                + "height=\"40\" style=\"fill:black\"/>\n" + "</svg>\n");
    }
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

    ////                         public methods                    ////
    public void fire() throws IllegalActionException {
        super.fire();
        int inputWidth = input.getWidth();
        Iterator outputPorts = outputPortList().iterator();
        TypedIOPort outputPort = (TypedIOPort) (outputPorts.hasNext() ? outputPorts
                .next()
                : null);
        int outputWidth = (outputPort != null) ? outputPort.getWidth() : 0;
        int j = 0;

        for (int i = 0; i < inputWidth; i++) {
            if (input.hasToken(i)) {
                Token t = input.get(i);

                if (outputPort != null) {
                    outputPort.send(j, t);
                }
            }

            if (outputPort != null) {
                if (j < (outputWidth - 1)) {
                    j++;
                } else {
                    outputPort = (TypedIOPort) (outputPorts.hasNext() ? outputPorts
                            .next()
                            : null);
                    outputWidth = (outputPort != null) ? outputPort.getWidth()
                            : 0;
                    j = 0;
                }
            }
        }
View Full Code Here

Examples of ptolemy.actor.TypedIOPort

        input.setMultiport(true);
        new Parameter(input, "signalType", new StringToken("CONTINUOUS"));
        output.setMultiport(true);
        output.setTypeAtLeast(input);
        new Parameter(output, "signalType", new StringToken("DISCRETE"));
        trigger = new TypedIOPort(this, "trigger", true, false);
        trigger.setMultiport(false);
        new Parameter(trigger, "signalType", new StringToken("DISCRETE"));

        // The trigger input has a generic type.
        _attachText("_iconDescription", "<svg>\n"
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.