Examples of IOPort


Examples of ptolemy.actor.IOPort

        Schedule schedule = new Schedule();
        Actor lastActor = null;
        Actor actor = null;

        for (int i = 0; i < sort.length; i++) {
            IOPort ioPort = (IOPort) sort[i];

            // If this ioPort is input but has no connections,
            // we ignore it.
            if (ioPort.isInput() && (ioPort.numLinks() == 0)) {
                continue;
            }

            actor = (Actor) ioPort.getContainer();

            // If the actor is the container of this director (which
            // can occur if this director is not at the top level),
            // then skip this actor. The container of the director
            // should not be listed in the schedule.
View Full Code Here

Examples of ptolemy.actor.IOPort

                .getDirector();

        for (Iterator portsIterator = connections.keySet().iterator(); portsIterator
                .hasNext();) {
            String portName = (String) portsIterator.next();
            IOPort port = (IOPort) ((ComponentEntity) actor).getPort(portName);
            DistributedTypedIORelation relation = null;

            if (port.isInput()) {
                Integer[][] integerReceivers = (Integer[][]) connections
                        .get(portName);

                if (VERBOSE) {
                    System.out.println("Receivers received for "
                            + portName
                            + "\n"
                            + DistributedUtilities
                                    .integersArrayToString(integerReceivers));
                }

                for (int i = 0; i < integerReceivers.length; i++) {
                    try {
                        relation = (DistributedTypedIORelation) compositeActor
                                .newRelation(portName + number);
                        number += 1;

                        if (VERBOSE) {
                            System.out.println("> for Port : " + portName
                                    + " created Relation: "
                                    + relation.getName());
                        }

                        port.link(relation);
                    } catch (NameDuplicationException e) {
                        KernelException.stackTraceToString(e);
                    } catch (IllegalActionException e) {
                        KernelException.stackTraceToString(e);
                    }
                }

                director.setListOfIds(DistributedUtilities
                        .convertIntegersToList(integerReceivers));

                try {
                    port.createReceivers();
                } catch (IllegalActionException e) {
                    KernelException.stackTraceToString(e);
                }

                if (VERBOSE) {
                    System.out.println("Receivers created for "
                            + portName
                            + "\n"
                            + DistributedUtilities.receiversArrayToString(port
                                    .getReceivers()));
                }
            }

            if (port.isOutput()) {
                try {
                    relation = (DistributedTypedIORelation) compositeActor
                            .newRelation(portName);

                    if (VERBOSE) {
                        System.out.println("> for Port : " + portName
                                + " created Relation: " + relation.getName());
                    }

                    port.link(relation);
                } catch (NameDuplicationException e) {
                    KernelException.stackTraceToString(e);
                } catch (IllegalActionException e) {
                    KernelException.stackTraceToString(e);
                }
View Full Code Here

Examples of ptolemy.actor.IOPort

        // to the same external input port.  See
        // BaseSDFScheduler.setContainerRates.
        Iterator ports = model.portList().iterator();

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

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

            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()) {
                List sinks = port.insideSinkPortList();

                if (sinks.size() > 0) {
                    IOPort connectedPort = (IOPort) sinks.get(0);
                    Entity entity = (Entity) connectedPort.getContainer();
                    String name = connectedPort.getName(model);
                    String identifier = name.replaceAll("\\.", "::");

                    String sinkExpression;
                    Variable sinkRateVariable = DFUtilities.getRateVariable(
                            connectedPort, "tokenConsumptionRate");

                    if (sinkRateVariable == null) {
                        sinkExpression = "1";
                    } else {
                        sinkExpression = identifier + "::"
                                + sinkRateVariable.getName();
                    }

                    String expression = sinkExpression + " * "
                            + entity.getName() + "::firingsPerIteration";

                    DFUtilities.setExpressionIfNotDefined(port,
                            "tokenConsumptionRate", expression);

                    if (_debugging && VERBOSE) {
                        _debug("Setting tokenConsumptionRate to " + expression);
                    }
                }
            } else if (port.isOutput()) {
                List sources = port.insideSourcePortList();

                if (sources.size() > 0) {
                    IOPort connectedPort = (IOPort) sources.get(0);
                    Entity entity = (Entity) connectedPort.getContainer();
                    String name = connectedPort.getName(model);
                    String identifier = name.replaceAll("\\.", "::");
                    Variable sourceRateVariable = DFUtilities.getRateVariable(
                            connectedPort, "tokenProductionRate");
                    String sourceExpression;

View Full Code Here

Examples of ptolemy.actor.IOPort

     */
    public void putArrayToAll(Token[] tokens, int numberOfTokens,
            Receiver[] receivers) throws NoRoomException,
            IllegalActionException, TerminateProcessException {
        if (numberOfTokens > tokens.length) {
            IOPort container = getContainer();
            throw new IllegalActionException(container,
                    "Not enough tokens supplied.");
        }

        for (int i = 0; i < numberOfTokens; i++) {
View Full Code Here

Examples of ptolemy.actor.IOPort

                while (edges.hasNext()) {
                    Edge nextEdge = (Edge) edges.next();
                    PSDFEdgeWeight weight = (PSDFEdgeWeight) nextEdge
                            .getWeight();
                    IOPort sourcePort = weight.getSourcePort();
                    List relationList = sourcePort.linkedRelationList();

                    if (relationList.size() != 1) {
                        // FIXME: Need to generalize this?
                        throw new RuntimeException("Cannot handle relation "
                                + "lists that are not singletons.\n"
View Full Code Here

Examples of ptolemy.actor.IOPort

                            if (receiver != null) {
                                receiver._putWaiting = theThread;
                                receiver._putReceivers = putReceivers;

                                IOPort port = receiver.getContainer();
                                if (isPutConditional) {
                                    receiver._putConditional = true;
                                    receiver._token = token == null ? null
                                            : port.convert(token);
                                } else {
                                    receiver._putConditional = false;
                                    try {
                                        token = tokenArray[i][j];
                                    } catch (Throwable e) {
                                    }
                                    receiver._token = token == null ? null
                                            : port.convert(token);
                                }

                                if (isSymmetric) {
                                    receiver._symmetricGetReceivers = getReceivers;
                                }
View Full Code Here

Examples of ptolemy.actor.IOPort

                ports = ((Actor) actor).outputPortList().iterator();
            } else {
                ports = ((Actor) actor).inputPortList().iterator();
            }
            while (ports.hasNext()) {
                IOPort port = (IOPort) ports.next();
                Iterator connectedPorts = port.connectedPortList().iterator();
                while (connectedPorts.hasNext()) {
                    IOPort otherPort = (IOPort) connectedPorts.next();
                    // Skip ports with the same polarity (input or output)
                    // as the current port.
                    if (port.isInput() && !otherPort.isOutput()
                            || port.isOutput() && !otherPort.isInput()) {
                        continue;
                    }
                    NamedObj higherActor = otherPort.getContainer();
                    _addHighlights(higherActor, moml, visited, forward, clear);
                }
            }
        }
    }
View Full Code Here

Examples of ptolemy.actor.IOPort

                    throw new IllegalActionException(this, ex,
                            "Expression invalid.");
                }

                if (nextDestination instanceof IOPort) {
                    IOPort destination = (IOPort) nextDestination;

                    try {
                        if (channel != null) {
                            if (token == null) {
                                destination.sendClear(channel.intValue());

                                if (_debugging) {
                                    _debug(getFullName() + " port: "
                                            + destination.getName()
                                            + " channel: " + channel.intValue()
                                            + ", Clear!");
                                }
                            } else {
                                destination.send(channel.intValue(), token);

                                if (_debugging) {
                                    _debug(getFullName() + " port: "
                                            + destination.getName()
                                            + " channel: " + channel.intValue()
                                            + ", token: " + token);
                                }
                            }
                        } else {
                            if (token == null) {
                                destination.broadcastClear();

                                if (_debugging) {
                                    _debug(getFullName() + " port: "
                                            + destination.getName()
                                            + " broadcast Clear!");
                                }
                            } else {
                                destination.broadcast(token);

                                if (_debugging) {
                                    _debug(getFullName() + " port: "
                                            + destination.getName()
                                            + " broadcast token: " + token);
                                }
                            }
                        }
                    } catch (NoRoomException ex) {
                        throw new IllegalActionException(this,
                                "Cannot complete action: " + ex.getMessage());
                    } catch (UnknownResultException ex) {
                        // Produce no output.
                    }
                } else if (nextDestination instanceof Variable) {
                    Variable destination = (Variable) nextDestination;

                    try {
                        //Token token = variable.getToken();
                        destination.setToken(token);

                        // Force all dependents to re-evaluate.
                        // This makes the parameters in the actors of
                        // the refinement take on new values immediately
                        // after the action is committed.
                        destination.validate();

                        if (_debugging) {
                            _debug(getFullName() + " variable: "
                                    + destination.getName() + ", value: "
                                    + token);
                        }
                    } catch (UnknownResultException ex) {
                        destination.setUnknown(true);
                    }
                } else {
                    throw new IllegalActionException(this,
                            "Destination is neither an IOPort nor a Variable: "
                                    + nextDestination.getFullName());
View Full Code Here

Examples of ptolemy.actor.IOPort

        if (fsm == null) {
            throw new IllegalActionException(this, transition,
                    "Transition has no container.");
        }

        IOPort port = (IOPort) fsm.getPort(name);

        if (port == null) {
            // No port found.  Try for a variable.
            Attribute variable = fsm.getAttribute(name);

            if (variable == null) {
                // Try for a refinement variable.
                int period = name.indexOf(".");

                if (period > 0) {
                    String refinementName = name.substring(0, period);
                    String entryName = name.substring(period + 1);

                    // FIXME: Look in the container of the fsm???
                    // Below we look for an attribute only in the fsm
                    // itself.
                    Nameable fsmContainer = fsm.getContainer();

                    if (fsmContainer instanceof CompositeEntity) {
                        Entity refinement = ((CompositeEntity) fsmContainer)
                                .getEntity(refinementName);

                        if (refinement != null) {
                            Attribute entry = refinement
                                    .getAttribute(entryName);

                            if (entry instanceof Variable) {
                                return entry;
                            }
                        }
                    }
                }

                throw new IllegalActionException(fsm, this,
                        "Cannot find port or variable with the name: " + name);
            } else {
                if (!(variable instanceof Variable)) {
                    throw new IllegalActionException(fsm, this,
                            "The attribute with name \"" + name
                                    + "\" is not an " + "instance of Variable.");
                }

                return variable;
            }
        } else {
            if (!port.isOutput()) {
                throw new IllegalActionException(fsm, this,
                        "The port is not an output port: " + name);
            }

            return port;
View Full Code Here

Examples of ptolemy.actor.IOPort

        LinkedList newRelationList = new LinkedList();
        Iterator inputPorts = transition.inputPortList().iterator();

        while (inputPorts.hasNext()) {
            IOPort inPort = (IOPort) inputPorts.next();
            newRelationList.addAll(inPort.linkedRelationList());
        }

        LinkedList temporarySourcePortList = new LinkedList();

        while (newRelationList.size() > 0) {
            IORelation weights = (IORelation) newRelationList.getFirst();

            if (weights != null) {
                Iterator weightPorts = weights.linkedSourcePortList()
                        .iterator();

                while (weightPorts.hasNext()) {
                    IOPort weightPort = (IOPort) weightPorts.next();

                    if (!temporarySourcePortList.contains(weightPort)) {
                        temporarySourcePortList.add(weightPort);

                        Nameable weightPlace = weightPort.getContainer();

                        if (weightPlace instanceof PetriNetActor) {
                            if (weightPort.isOutput()) {
                                newRelationList.addAll(weightPort
                                        .insideRelationList());
                            } else if (weightPort.isInput()) {
                                newRelationList.addAll(weightPort
                                        .linkedRelationList());
                            }
                        }
                    }
                }
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.