Package ptolemy.actor

Examples of ptolemy.actor.IOPort


        }

        Iterator ports = inputPortList().iterator();

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

            // Do not
            if (port instanceof ParameterPort) {
                PortParameter parameter = ((ParameterPort) port).getParameter();

                if (_debugging) {
                    _debug("** Updating PortParameter: " + port.getName());
                }

                parameter.update();
                continue;
            }

            if ((port.getWidth() > 0) && port.hasToken(0)) {
                Token token = port.get(0);
                Attribute attribute = getAttribute(port.getName());

                // Use the token directly rather than a string if possible.
                if (attribute instanceof Variable) {
                    if (_debugging) {
                        _debug("** Transferring input to parameter: "
                                + port.getName());
                    }

                    ((Variable) attribute).setToken(token);
                } else if (attribute instanceof Settable) {
                    if (_debugging) {
                        _debug("** Transferring input as string to parameter: "
                                + port.getName());
                    }

                    ((Settable) attribute).setExpression(token.toString());
                }
            }
View Full Code Here


        }

        Iterator ports = outputPortList().iterator();

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

            // Only write if the port has a connected channel.
            if (port.getWidth() > 0) {
                Attribute attribute = getAttribute(port.getName());

                // Use the token directly rather than a string if possible.
                if (attribute instanceof Variable) {
                    if (_debugging) {
                        _debug("** Transferring parameter to output: "
                                + port.getName());
                    }

                    port.send(0, ((Variable) attribute).getToken());
                } else if (attribute instanceof Settable) {
                    if (_debugging) {
                        _debug("** Transferring parameter as string to output: "
                                + port.getName());
                    }

                    port.send(0, new StringToken(((Settable) attribute)
                            .getExpression()));
                }
            }
        }
    }
View Full Code Here

        boolean changeMade = false;

        Iterator ports = inputPortList().iterator();

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

            if (port instanceof ParameterPort) {
                PortParameter parameter = ((ParameterPort) port).getParameter();

                if (_debugging) {
                    _debug("** Updating PortParameter: " + port.getName());
                }

                parameter.update();
                changeMade = true;
                continue;
            }

            if ((port.getWidth() > 0) && port.hasToken(0)) {
                Token token = port.get(0);

                if (_model != null) {
                    Attribute attribute = _model.getAttribute(port.getName());

                    // Use the token directly rather than a string if possible.
                    if (attribute instanceof Variable) {
                        if (_debugging) {
                            _debug("** Transferring input to parameter: "
                                    + port.getName());
                        }

                        ((Variable) attribute).setToken(token);
                        changeMade = true;
                    } else if (attribute instanceof Settable) {
                        if (_debugging) {
                            _debug("** Transferring input as string to parameter: "
                                    + port.getName());
                        }

                        ((Settable) attribute).setExpression(token.toString());
                        changeMade = true;
                    }
View Full Code Here

        }

        Iterator ports = outputPortList().iterator();

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

            // Only write if the port has a connected channel.
            if (port.getWidth() > 0) {
                Attribute attribute = _model.getAttribute(port.getName());

                // Use the token directly rather than a string if possible.
                if (attribute instanceof Variable) {
                    if (_debugging) {
                        _debug("** Transferring parameter to output: "
                                + port.getName());
                    }

                    port.send(0, ((Variable) attribute).getToken());
                } else if (attribute instanceof Settable) {
                    if (_debugging) {
                        _debug("** Transferring parameter as string to output: "
                                + port.getName());
                    }

                    port.send(0, new StringToken(((Settable) attribute)
                            .getExpression()));
                }
            }
        }
    }
View Full Code Here

                                    .next();
                            String name = insidePort.getName();

                            // The outside port may already exist (e.g.
                            // as a consequence of cloning).
                            IOPort newPort = (IOPort) getPort(name);

                            if (newPort == null) {
                                newPort = (IOPort) newPort(name);
                            }

                            if (insidePort instanceof IOPort) {
                                IOPort castPort = (IOPort) insidePort;
                                newPort.setMultiport(castPort.isMultiport());
                                newPort.setInput(castPort.isInput());
                                newPort.setOutput(castPort.isOutput());
                            }

                            // Set up inside connections.
                            // Do this only if they are not already connected.
                            List connectedPorts = insidePort
View Full Code Here

                            if (insidePort == null) {
                                insidePort = insideEntity.newPort(portName);

                                if (insidePort instanceof IOPort) {
                                    IOPort castInsidePort = (IOPort) insidePort;
                                    castInsidePort.setInput(castPort.isInput());
                                    castInsidePort.setOutput(castPort
                                            .isOutput());
                                    castInsidePort.setMultiport(castPort
                                            .isMultiport());
                                }
                            }

                            if (insidePort instanceof MirrorPort) {
View Full Code Here

                    // the actor, which is not reliable.
                    boolean outOfData = true;
                    Iterator inPorts = actor.inputPortList().iterator();

                    while (inPorts.hasNext()) {
                        IOPort port = (IOPort) inPorts.next();

                        for (int i = 0; i < port.getWidth(); i++) {
                            if (port.hasToken(i)) {
                                outOfData = false;
                                break;
                            }
                        }
                    }
View Full Code Here

            // Transfer input tokens.
            for (Iterator inputPorts = container.inputPortList().iterator(); inputPorts
                    .hasNext()
                    && !_stopRequested;) {
                IOPort port = (IOPort) inputPorts.next();

                if (!(port instanceof ParameterPort)) {
                    Receiver[][] insideReceivers = port.deepGetReceivers();
                    for (int i = 0; i < port.getWidth(); i++) {
                        if (port.hasToken(i)) {
                            Token token = port.get(i);
                            if ((insideReceivers != null)
                                    && (insideReceivers[i] != null)) {
                                for (int j = 0; j < insideReceivers[i].length; j++) {
                                    if (insideReceivers[i][j].getContainer()
                                            .getContainer() == refinement) {
                                        insideReceivers[i][j].put(token);
                                        if (_debugging) {
                                            _debug(
                                                    getFullName(),
                                                    "transferring input from "
                                                            + port
                                                                    .getFullName()
                                                            + " to "
                                                            + (insideReceivers[i][j])
                                                                    .getContainer()
                                                                    .getFullName());
View Full Code Here

            // Use the local director to transfer outputs.
            Iterator outports = outputPortList().iterator();

            while (outports.hasNext() && !_stopRequested) {
                IOPort p = (IOPort) outports.next();
                _director.transferOutputs(p);
            }
        } finally {
            _workspace.doneReading();
        }
View Full Code Here

     @exception IllegalActionException If there is no container port, or
     *   if the port has no container actor, or if the actor has no director,
     *   or if the director is not an instance of TMDirector.
     */
    public TMDirector getDirector() throws IllegalActionException {
        IOPort port = getContainer();

        if (port != null) {
            if (_directorVersion == port.workspace().getVersion()) {
                return _director;
            }

            // Cache is invalid.  Reconstruct it.
            try {
                port.workspace().getReadAccess();

                Actor actor = (Actor) port.getContainer();

                if (actor != null) {
                    Director director;

                    if ((port.isOutput()) && (actor instanceof CompositeActor)
                            && ((CompositeActor) actor).isOpaque()) {
                        director = actor.getDirector();
                    } else {
                        director = actor.getExecutiveDirector();
                    }

                    if (director != null) {
                        if (director instanceof TMDirector) {
                            _director = (TMDirector) director;
                            _directorVersion = port.workspace().getVersion();
                            return _director;
                        } else {
                            throw new IllegalActionException(getContainer(),
                                    "Does not have a TMDirector.");
                        }
                    }
                }
            } finally {
                port.workspace().doneReading();
            }
        }

        throw new IllegalActionException(getContainer(),
                "Does not have a IOPort as the container of the receiver.");
View Full Code Here

TOP

Related Classes of ptolemy.actor.IOPort

Copyright © 2018 www.massapicom. 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.