Examples of IOPort


Examples of ptolemy.actor.IOPort

     *  execute in the same thread as the director.
     *  @param token The token to be put.
     */
    public synchronized void put(Token token) {
        try {
            IOPort port = getContainer();

            if (port == null) {
                throw new InternalErrorException(
                        "put() requires that the port has a container");
            }

            Parameter priority = (Parameter) port.getAttribute("priority");

            if (priority == null) {
                if (port.getContainer() == null) {
                    throw new InternalErrorException(
                            "put() requires that the port '"
                                    + port
                                    + "' that contains this receiver be itself "
                                    + "contained");
                }

                priority = (Parameter) port.getContainer().getAttribute(
                        "priority");
            }

            int priorityValue = 5;

View Full Code Here

Examples of ptolemy.actor.IOPort

        CompositeActor container = (CompositeActor) getContainer();

        for (Iterator ports = container.outputPortList().iterator(); ports
                .hasNext();) {
            IOPort port = (IOPort) ports.next();

            // Create external initial production.
            int rate = DFUtilities.getTokenInitProduction(port);

            for (int i = 0; i < port.getWidthInside(); i++) {
                try {
                    for (int k = 0; k < rate; k++) {
                        if (port.hasTokenInside(i)) {
                            Token t = port.getInside(i);

                            if (_debugging) {
                                _debug(getName(), "transferring output from "
                                        + port.getName());
                            }

                            port.send(i, t);
                        } else {
                            throw new IllegalActionException(this, port,
                                    "Port should produce " + rate
                                            + " tokens, but there were only "
                                            + k + " tokens available.");
View Full Code Here

Examples of ptolemy.actor.IOPort

        TypedCompositeActor container = ((TypedCompositeActor) getContainer());
        Iterator inputPorts = container.inputPortList().iterator();

        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();

            // NOTE: If the port is a ParameterPort, then we should not
            // insist on there being an input.
            if (inputPort instanceof ParameterPort) {
                continue;
            }

            int threshold = DFUtilities.getTokenConsumptionRate(inputPort);

            if (_debugging) {
                _debug("checking input " + inputPort.getFullName());
                _debug("Threshold = " + threshold);
            }

            for (int channel = 0; channel < inputPort.getWidth(); channel++) {
                if ((threshold > 0) && !inputPort.hasToken(channel, threshold)) {
                    if (_debugging) {
                        _debug("Port " + inputPort.getFullName()
                                + " does not have enough tokens: " + threshold
                                + " Prefire returns false.");
                    }

                    return false;
View Full Code Here

Examples of ptolemy.actor.IOPort

            // Find the successors of the actor
            Set successors = new HashSet();
            Iterator outports = actor.outputPortList().iterator();

            while (outports.hasNext()) {
                IOPort outPort = (IOPort) outports.next();
                Iterator sinkPorts = outPort.sinkPortList().iterator();

                while (sinkPorts.hasNext()) {
                    IOPort sinkPort = (IOPort) sinkPorts.next();

                    if (sinkPort.isOutput()) {
                        // Skip this port, since its part of the container
                        continue;
                    }

                    Actor sinkActor = (Actor) sinkPort.getContainer();
                    successors.add(sinkActor);
                }
            }

            // Add the edge in the DAG
View Full Code Here

Examples of ptolemy.actor.IOPort

        // will change their status and until then an iteration is claimed
        // complete.
        Iterator inputPorts = controller.inputPortList().iterator();

        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();
            if (!inputPort.isKnown()) {
                return;
            }
        }

        // See whether there is an enabled transition.
View Full Code Here

Examples of ptolemy.actor.IOPort

                        updates.put(ColumnNames.COL_NAME, Boolean.TRUE);
                    }
                }

                if (actualPort instanceof IOPort) {
                    IOPort iop = (IOPort) actualPort;

                    if (_columnNames.contains(ColumnNames.COL_INPUT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_INPUT);

                        if (iop.isInput() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates.put(ColumnNames.COL_INPUT, Boolean.TRUE);
                        }
                    }

                    if (_columnNames.contains(ColumnNames.COL_OUTPUT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_OUTPUT);

                        if (iop.isOutput() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates.put(ColumnNames.COL_OUTPUT, Boolean.TRUE);
                        }
                    }

                    if (_columnNames.contains(ColumnNames.COL_MULTIPORT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_MULTIPORT);

                        if (iop.isMultiport() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates
                                    .put(ColumnNames.COL_MULTIPORT,
                                            Boolean.TRUE);
                        }
View Full Code Here

Examples of ptolemy.actor.IOPort

                        portInfo.put(ColumnNames.COL_HIDE, Boolean.FALSE);
                    }
                }

                if (p instanceof IOPort) {
                    IOPort iop = (IOPort) p;

                    if (_columnNames.contains(ColumnNames.COL_INPUT)) {
                        portInfo.put(ColumnNames.COL_INPUT, Boolean.valueOf(iop
                                .isInput()));
                    }

                    if (_columnNames.contains(ColumnNames.COL_OUTPUT)) {
                        portInfo.put(ColumnNames.COL_OUTPUT, Boolean
                                .valueOf(iop.isOutput()));
                    }

                    if (_columnNames.contains(ColumnNames.COL_MULTIPORT)) {
                        portInfo.put(ColumnNames.COL_MULTIPORT, Boolean
                                .valueOf(iop.isMultiport()));
                    }
                }

                if (p instanceof TypedIOPort) {
                    TypedIOPort tiop = (TypedIOPort) p;
View Full Code Here

Examples of ptolemy.actor.IOPort

            Iterator labels = record.labelSet().iterator();

            while (labels.hasNext()) {
                String label = (String) labels.next();
                Token value = record.get(label);
                IOPort port = (IOPort) getPort(label);

                // since the record received may contain more fields than the
                // output ports, some fields may not have a corresponding
                // output port.
                if (port != null) {
                    port.send(0, value);
                }
            }
        }
    }
View Full Code Here

Examples of ptolemy.actor.IOPort

                List tokensFromAllInputPorts = new LinkedList();

                for (Iterator inputPorts = inputPortList().iterator(); inputPorts
                        .hasNext()
                        && !_stopRequested;) {
                    IOPort port = (IOPort) inputPorts.next();
                    if (!(port instanceof ParameterPort)) {
                        Object tokens = _transferInputs(port);
                        tokensFromAllInputPorts.add(tokens);
                    }
                }

                if (_stopRequested) {
                    return;
                }

                Object[] tokensToAllOutputPorts = null;
                try {
                    // Invoke the native fire method
                    tokensToAllOutputPorts = (Object[]) _jniFireMethod.invoke(
                            _jniWrapper, tokensFromAllInputPorts.toArray());
                } catch (Throwable throwable) {
                    throw new IllegalActionException(this, throwable,
                            "Failed to invoke the fire method on "
                                    + "the wrapper class.");
                }

                if (_stopRequested) {
                    return;
                }

                int portNumber = 0;
                for (Iterator outputPorts = outputPortList().iterator(); outputPorts
                        .hasNext()
                        && !_stopRequested;) {
                    IOPort port = (IOPort) outputPorts.next();
                    _transferOutputs(port, tokensToAllOutputPorts[portNumber++]);
                }

            } finally {
                _workspace.doneReading();
View Full Code Here

Examples of ptolemy.actor.IOPort

        StringBuffer arguments = new StringBuffer();
        Iterator inputPorts = inputPortList().iterator();
        int i = 0;
        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();
            if (!(inputPort instanceof ParameterPort)) {

                if (i != 0) {
                    arguments.append(", ");
                }
                i++;
                //FIXME: need to consider carefully for structured data type
                Type type = ((TypedIOPort) inputPort).getType();
                String typeName = type.toString();
                if (typeName.equals("unknown") || typeName.equals("Pointer")) {
                    // If a port is not connected, then use int as a default.
                    typeName = "int";
                }
                arguments.append(typeName + "[][] " + inputPort.getName());
            }
        }
        return arguments.toString();
    }
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.