Examples of IORelation


Examples of ptolemy.actor.IORelation

                // the relation does not already exist, so we
                // create a new relation, create a link and a
                // _Link from the port to the new relation, and
                // add the _Link to the list of links.
                String relationName = _relations.getNewRelationName();
                relationFrom = new IORelation(_compositeActor, relationName);
                _interfaceRelationTable.put(interfaceFrom, relationFrom);
                portFrom.link(relationFrom);
                _Link link = new _Link(portFrom, relationFrom);
                _linkList.add(link);
            }
        } else {
            // This is a multi (parameterized) port, so we create
            // a new relation, add it to the relation list of the
            // interface, create a link and a _Link from the port
            // to the new relation, and add the _Link to the list
            // of links.
            String relationName = _relations.getNewRelationName();
            relationFrom = new IORelation(_compositeActor, relationName);
            if (_interfaceRelationTable.containsKey(interfaceFrom)) {
                // If the interface already has a relation list,
                // add the new relation to the list.
                Object o = _interfaceRelationTable.get(interfaceFrom);
                if (!(o instanceof ArrayList)) {
                    throw new InternalErrorException(
                            "Multiport should only be connected to an "
                                    + "ArrayList of Relation.");
                }
                ArrayList arrayList = (ArrayList) o;
                arrayList.add(relationFrom);
            } else {
                // If the interface does not already have a
                // relation list, create it and add the new
                // relation to the list.
                ArrayList arrayList = new ArrayList();
                arrayList.add(relationFrom);
                _interfaceRelationTable.put(interfaceFrom, arrayList);
            }
            portFrom.link(relationFrom);
            _Link link = new _Link(portFrom, relationFrom);
            _linkList.add(link);
        }

        // Determine the To Relation.
        Relation relationTo;
        if (interfaceTo.parameters == null) {
            if (_interfaceRelationTable.containsKey(interfaceTo)) {
                // This is a single (non-parameterized) port, and
                // the relation already exists, so we reuse it.
                Object o = _interfaceRelationTable.get(interfaceTo);
                if (!(o instanceof Relation)) {
                    throw new InternalErrorException(
                            "Single port should only be connected to a "
                                    + "Relation.");
                }
                relationTo = (Relation) o;
            } else {
                // This is a single (non-parameterized) port, and
                // the relation does not already exist, so we
                // create a new relation, create a link and a
                // _Link from the new relation to the port, and
                // add the _Link to the list of links.
                String relationName = _relations.getNewRelationName();
                relationTo = new IORelation(_compositeActor, relationName);
                _interfaceRelationTable.put(interfaceTo, relationTo);
                portTo.link(relationTo);
                _Link link = new _Link(relationTo, portTo);
                _linkList.add(link);
            }
        } else {
            // This is a multi (parameterized) port, so we create
            // a new relation, add it to the relation list of the
            // interface, create a link and a _Link from the new
            // relation to the port, and add the _Link to the list
            // of links.
            String relationName = _relations.getNewRelationName();
            relationTo = new IORelation(_compositeActor, relationName);
            if (_interfaceRelationTable.containsKey(interfaceTo)) {
                // If the interface already has a relation list,
                // add the new relation to the list.
                Object o = _interfaceRelationTable.get(interfaceTo);
                if (!(o instanceof ArrayList)) {
View Full Code Here

Examples of ptolemy.actor.IORelation

                        }

                        // For the edges at the boundary.
                        if ((!headOK && tailOK) || (headOK && !tailOK)) {
                            IOPort port = null;
                            IORelation relation = null;
                            boolean duplicateRelation = false;

                            if (head instanceof IOPort) {
                                port = (IOPort) head;

                                if (tail instanceof IOPort) {
                                    relation = (IORelation) graphModel
                                            .getSemanticObject(userObject);
                                    duplicateRelation = true;
                                } else {
                                    relation = (IORelation) graphModel
                                            .getSemanticObject(tail);
                                }
                            } else if (tail instanceof IOPort) {
                                port = (IOPort) tail;
                                relation = (IORelation) graphModel
                                        .getSemanticObject(head);
                            }

                            if (port != null) {
                                ComponentEntity entity = (ComponentEntity) port
                                        .getContainer();
                                String portName = "port_" + i;
                                boolean isInput = port.isInput();
                                boolean isOutput = port.isOutput();
                                newPorts
                                        .append("<port name=\""
                                                + portName
                                                + "\" class=\"ptolemy.actor.TypedIOPort"
                                                + "\">\n");

                                if (namedObjSet.contains(entity)) {
                                    // The port is inside the hierarchy.
                                    // The relation must be outside.
                                    // Create composite port.
                                    if (isInput) {
                                        newPorts
                                                .append("<property name=\"input\"/>");
                                    }

                                    if (isOutput) {
                                        newPorts
                                                .append("<property name=\"output\"/>");
                                    }

                                    newPorts.append("\n</port>\n");

                                    // Create internal relation and links.
                                    // Note we can only partially reuse
                                    // the relation name, one original relation
                                    // can be two internal relations.
                                    String relationName = relation.getName()
                                            + "_" + i;
                                    intRelations
                                            .append("<relation name=\""
                                                    + relationName
                                                    + "\" class=\""
                                                    + "ptolemy.actor.TypedIORelation\"/>\n");
                                    intConnections.append("<link port=\""
                                            + entity.getName() + "."
                                            + port.getName() + "\" relation=\""
                                            + relationName + "\"/>\n");
                                    intConnections.append("<link port=\""
                                            + portName + "\" relation=\""
                                            + relationName + "\"/>\n");

                                    // Create external links.
                                    if (duplicateRelation) {
                                        extRelations
                                                .append("<relation name=\""
                                                        + relation.getName()
                                                        + "\" class=\""
                                                        + "ptolemy.actor.TypedIORelation\"/>\n");

                                        IOPort otherPort = (IOPort) tail;
                                        ComponentEntity otherEntity = (ComponentEntity) otherPort
                                                .getContainer();

                                        if (otherEntity == container) {
                                            // This is a boundary port at a higher level.
                                            extConnections
                                                    .append("<link port=\""
                                                            + otherPort
                                                                    .getName()
                                                            + "\" relation=\""
                                                            + relation
                                                                    .getName()
                                                            + "\"/>\n");
                                        } else {
                                            extConnections
                                                    .append("<link port=\""
                                                            + otherEntity
                                                                    .getName()
                                                            + "."
                                                            + otherPort
                                                                    .getName()
                                                            + "\" relation=\""
                                                            + relation
                                                                    .getName()
                                                            + "\"/>\n");
                                        }
                                    }

                                    extConnections.append("<link port=\""
                                            + compositeActorName + "."
                                            + portName + "\" relation=\""
                                            + relation.getName() + "\"/>\n");
                                } else {
                                    // The port is outside the hierarchy.
                                    // The relation must be inside.
                                    if (isInput) {
                                        newPorts
                                                .append("<property name=\"output\"/>");
                                    }

                                    if (isOutput) {
                                        newPorts
                                                .append("<property name=\"input\"/>");
                                    }

                                    newPorts.append("\n</port>\n");

                                    String relationName = relation.getName()
                                            + "_" + i;
                                    extRelations
                                            .append("<relation name=\""
                                                    + relationName
                                                    + "\" class=\""
                                                    + "ptolemy.actor.TypedIORelation\"/>\n");
                                    extConnections.append("<link port=\""
                                            + entity.getName() + "."
                                            + port.getName() + "\" relation=\""
                                            + relationName + "\"/>\n");
                                    extConnections.append("<link port=\""
                                            + compositeActorName + "."
                                            + portName + "\" relation=\""
                                            + relationName + "\"/>\n");

                                    // Create external links.
                                    if (duplicateRelation) {
                                        intRelations
                                                .append("<relation name=\""
                                                        + relation.getName()
                                                        + "\" class=\""
                                                        + "ptolemy.actor.TypedIORelation\"/>\n");

                                        IOPort otherPort = (IOPort) tail;
                                        ComponentEntity otherEntity = (ComponentEntity) otherPort
                                                .getContainer();
                                        intConnections
                                                .append("<link port=\""
                                                        + otherEntity.getName()
                                                        + "."
                                                        + otherPort.getName()
                                                        + "\" relation=\""
                                                        + relation.getName()
                                                        + "\"/>\n");
                                    }

                                    intConnections.append("<link port=\""
                                            + portName + "\" relation=\""
                                            + relation.getName() + "\"/>\n");
                                }
                            }
                            //                        } else if (!headOK && !tailOK) {
                            //                            // We only selected an edge. Build one input
                            //                            // port, one output port for it, and build
View Full Code Here

Examples of ptolemy.actor.IORelation

                }
            }
        }

        for (int i = 0; i < relations.size(); i++) {
            IORelation relation = (IORelation) (relations.elementAt(i));
            List ports = relation.linkedPortList();
            IOPort inputPort = null;
            Iterator portIter = ports.iterator();

            while (portIter.hasNext()) {
                IOPort port = (IOPort) (portIter.next());
View Full Code Here

Examples of ptolemy.actor.IORelation

                IOPort port = (IOPort) source;
                ComponentEntity actor = (ComponentEntity) (port.getContainer());
                moml.append("<entity name=\"" + actor.getName() + "\">"
                        + _momlAnnotate(port, color, expression) + "</entity>");
            } else if (source instanceof IORelation) {
                IORelation relation = (IORelation) source;
                moml.append(_momlAnnotate(relation, color, expression));
            } else if (source instanceof ComponentEntity) {
                ComponentEntity componentEntity = (ComponentEntity) source;
                moml.append(_momlAnnotate(componentEntity, color, expression));
            }
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.