Package ptolemy.actor

Examples of ptolemy.actor.IOPort


    private void _transferOutputsToEnvironment() throws IllegalActionException {
        // If there are no output ports, this method does nothing.
        CompositeActor container = (CompositeActor) getContainer();
        Iterator outports = container.outputPortList().iterator();
        while (outports.hasNext() && !_stopRequested) {
            IOPort p = (IOPort) outports.next();
            super.transferOutputs(p);
        }
    }
View Full Code Here


     *   an entity already in the container.
     */
    public TestSink(CompositeActor container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        _input = new IOPort(this, "input", true, false);
    }
View Full Code Here

                _debug("Called getCharParameterValue with " + parameter
                        + " as argument.");
            }

            CompositeActor model = (CompositeActor) getContainer();
            IOPort port = (IOPort) model.getPort(parameter);
            if (port != null) {
                if (port instanceof ParameterPort) {
                    Token token = ((ParameterPort) port).getParameter()
                        .getToken();
                    if (token != null) {
View Full Code Here

            }
        }

        Iterator outPorts = model.outputPortList().iterator();
        while (outPorts.hasNext()) {
            IOPort port = (IOPort) outPorts.next();

            // FIXME: Assuming ports are either
            // input or output and not both.
            List sourcePortList = port.insidePortList();

            //FIXME: can the list be empty?

            CompositeActor container = (CompositeActor) getContainer();

            if ((sourcePortList != null)
                    && !(container instanceof PtinyOSCompositeActor)) {
                // FIXME: test this code
                for (int i = 0; i < sourcePortList.size(); i++) {
                    IOPort sourcePort = (IOPort) sourcePortList.get(i);
                    String sanitizedOutPortName = StringUtilities
                            .sanitizeName(sourcePort.getName());
                    String sourceActorName = StringUtilities
                            .sanitizeName(sourcePort.getContainer().getName());
                    codeString.addLine(sourceActorName + "."
                            + sanitizedOutPortName + " = " + port.getName()
                            + ";");
                }
            }
View Full Code Here

        Director director = (Director) getContainer();
        CompositeActor container = (CompositeActor) director.getContainer();
        Iterator ports = container.portList().iterator();

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

            if (_debugging && VERBOSE) {
                _debug("External Port " + port.getName());
            }

            Integer rate = (Integer) externalRates.get(port);

            if (port.isInput() && port.isOutput()) {
                throw new NotSchedulableException(port,
                        "External port is both an input and an output, "
                                + "which is not allowed in SDF.");
            } else if (port.isInput()) {
                DFUtilities.setIfNotDefined(port, "tokenConsumptionRate", rate
                        .intValue());

                if (_debugging && VERBOSE) {
                    _debug("Setting tokenConsumptionRate to " + rate.intValue());
                }
            } else if (port.isOutput()) {
                DFUtilities.setIfNotDefined(port, "tokenProductionRate", rate
                        .intValue());

                if (_debugging && VERBOSE) {
                    _debug("Setting tokenProductionRate to " + rate.intValue());
                }

                // Infer init production.
                // Note that this is a very simple type of inference...
                // However, in general, we don't want to try to
                // flatten this model...
                Iterator connectedPorts = port.insideSourcePortList()
                        .iterator();
                IOPort foundOutputPort = null;
                int inferredRate = 0;

                while (connectedPorts.hasNext()) {
                    IOPort connectedPort = (IOPort) connectedPorts.next();

                    int newRate;

                    if (connectedPort.isOutput()) {
                        newRate = DFUtilities
                                .getTokenInitProduction(connectedPort);
                    } else {
                        newRate = 0;
                    }
View Full Code Here

        String actorName = StringUtilities.sanitizeName(((NamedObj) actor)
                .getName());

        for (Iterator inPorts = actor.inputPortList().iterator(); inPorts
                .hasNext();) {
            IOPort inPort = (IOPort) inPorts.next();
            String sanitizedInPortName = StringUtilities.sanitizeName(inPort
                    .getName());
            String inPortMultiport = "";

            if (inPort.isMultiport()) {
                inPortMultiport = "[unique(\"" + sanitizedInPortName + "\")]";
            }

            List sourcePortList = inPort.sourcePortList();

            // Note: We allow an input port (provides) to connect to
            // multiple output ports (requires).  The nesC compiler
            // will generate a warning about uncombined calls in that
            // case.
            for (int i = 0; i < sourcePortList.size(); i++) {
                IOPort sourcePort = (IOPort) sourcePortList.get(i);
                String sanitizedSourcePortName = StringUtilities
                        .sanitizeName(sourcePort.getName());
                String sourcePortMultiport = "";

                if (sourcePort.isMultiport()) {
                    sourcePortMultiport = "[unique(\""
                            + sanitizedSourcePortName + "\")]";
                }

                String sourceActorName = StringUtilities
                        .sanitizeName(sourcePort.getContainer().getName());

                if (sourcePort.getContainer() == model) {
                    codeString.addLine(sanitizedSourcePortName
                            + sourcePortMultiport + " = " + actorName + "."
                            + sanitizedInPortName + inPortMultiport + ";");
                } else {
                    codeString.addLine(sourceActorName + "."
View Full Code Here

        _CodeString codeString = new _CodeString();

        Iterator inPorts = model.inputPortList().iterator();

        while (inPorts.hasNext()) {
            IOPort port = (IOPort) inPorts.next();
            if (port.isOutput()) {
                throw new IllegalActionException(port,
                        "Ports that are both inputs and outputs "
                                + "are not allowed.");
            }
            codeString.addLine("provides interface " + port.getName() + ";");
        }

        return codeString.toString();
    }
View Full Code Here

        _CodeString codeString = new _CodeString();

        Iterator outPorts = model.outputPortList().iterator();

        while (outPorts.hasNext()) {
            IOPort port = (IOPort) outPorts.next();
            if (port.isInput()) {
                throw new IllegalActionException(port,
                        "Ports that are both inputs and outputs "
                                + "are not allowed.");
            }
            codeString.addLine("uses interface " + port.getName() + ";");
        }

        return codeString.toString();
    }
View Full Code Here

        //register this property transformer for the connected wireless
        //output port. It assumes there is only one.
        Iterator connectedOutputPorts = output.sinkPortList().iterator();

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

            if (port.isOutput() && port instanceof WirelessIOPort) {
                // Found the port.
                foundOne = true;

                Entity container = (Entity) (port.getContainer());
                String channelName = ((WirelessIOPort) port).outsideChannel
                        .stringValue();
                CompositeEntity container2 = (CompositeEntity) container
                        .getContainer();

                if (container2 == null) {
                    throw new IllegalActionException(this,
                            "The port's container does not have a container.");
                }

                Entity channel = container2.getEntity(channelName);

                if (channel instanceof WirelessChannel) {
                    // Cache it here, so no need to do it again in wrapup().
                    _outputWirelessChannel = (WirelessChannel) channel;
                    _wirelessOutputPort = (WirelessIOPort) port;
                    ((WirelessChannel) channel).registerPropertyTransformer(
                            this, (WirelessIOPort) port);
                } else {
                    throw new IllegalActionException(this,
                            "The connected output port does not refer to a "
                                    + "valid channel.");
                }
            }
        }

        //register this property transformer for the connected wireless
        //input port. It assumes there is only one.
        Iterator connectedInputPorts = input.sourcePortList().iterator();

        while (connectedInputPorts.hasNext()) {
            //register this property transformer for the connected wireless
            //output port. It assumes there is only one.
            IOPort port = (IOPort) connectedInputPorts.next();

            if (port.isInput() && port instanceof WirelessIOPort) {
                // Found the port.
                foundOne = true;

                Entity container = (Entity) (port.getContainer());
                String channelName = ((WirelessIOPort) port).outsideChannel
                        .stringValue();
                CompositeEntity container2 = (CompositeEntity) container
                        .getContainer();
View Full Code Here

        StringBuffer rates = new StringBuffer();

        Iterator inputPorts = _inputPortList.iterator();

        while (inputPorts.hasNext()) {
            IOPort inputPort = (IOPort) inputPorts.next();
            int rate = DFUtilities.getTokenConsumptionRate(inputPort);
            rates.append(rate);
        }

        Iterator outputPorts = _outputPortList.iterator();

        while (outputPorts.hasNext()) {
            IOPort outputPort = (IOPort) outputPorts.next();
            int rate = DFUtilities.getTokenProductionRate(outputPort);
            rates.append(rate);

            /*int initRate = */DFUtilities.getTokenInitProduction(outputPort);
            rates.append(rate);
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.