Package ptolemy.kernel

Examples of ptolemy.kernel.ComponentPort


            try {
                _inConnectionsChanged = true;

                while (insidePorts.hasNext()) {
                    ComponentPort insidePort = (ComponentPort) insidePorts
                            .next();
                    Entity portContainer = (Entity) insidePort.getContainer();

                    // Avoid an infinite loop where notifications are traded.
                    if (!(portContainer instanceof CompositeActor)
                            || !((CompositeActor) portContainer)._inConnectionsChanged) {
                        portContainer.connectionsChanged(insidePort);
View Full Code Here


    private void _links(JimpleBody body, CompositeEntity composite) {
        // To get the ordering right,
        // we read the links from the ports, not from the relations.
        // First, produce the inside links on contained ports.
        for (Iterator ports = composite.portList().iterator(); ports.hasNext();) {
            ComponentPort port = (ComponentPort) ports.next();
            Iterator relations = port.insideRelationList().iterator();
            int index = -1;

            while (relations.hasNext()) {
                index++;
View Full Code Here

                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();
            Iterator ports = entity.portList().iterator();

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

                Local portLocal;

                // If we already have a local reference to the port
                if (_portLocalMap.keySet().contains(port)) {
                    // then just get the reference.
                    portLocal = (Local) _portLocalMap.get(port);
                } else {
                    throw new RuntimeException("Found a port: " + port
                            + " that does not have a local variable!");
                }

                Iterator relations = port.linkedRelationList().iterator();
                int index = -1;

                while (relations.hasNext()) {
                    index++;
View Full Code Here

                if (head instanceof State && tail instanceof State) {
                    // When we connect two states, we actually connect the
                    // appropriate ports.
                    State headState = (State) head;
                    State tailState = (State) tail;
                    ComponentPort headPort = headState.incomingPort;
                    ComponentPort tailPort = tailState.outgoingPort;
                    NamedObj ptolemyModel = getPtolemyModel();

                    // If the context is not the entity that we're editing,
                    // then we need to set the context correctly.
                    if (ptolemyModel != container) {
                        String contextString = "<entity name=\""
                                + ptolemyModel.getName(container) + "\">\n";
                        moml.append(contextString);
                        failmoml.append(contextString);
                    }

                    boolean createdNewRelation = false;
                    String relationName = null;

                    if (linkRelation != null) {
                        // Pre-existing relation. Use it.
                        relationName = linkRelation.getName(ptolemyModel);
                    } else {
                        createdNewRelation = true;

                        // Linking two ports with a new relation.
                        relationName = ptolemyModel.uniqueName("relation");

                        // Set the exitAngle based on other relations.
                        // Count the number of connections between the
                        // headPort and the tailPort.
                        Iterator ports = tailPort.deepConnectedPortList()
                                .iterator();
                        int count = 0;

                        while (ports.hasNext()) {
                            if (ports.next() == headPort) {
                                count++;
                            }
                        }

                        // Increase the angle as the count increases.
                        // Any function of "count" will work here that starts
                        // at PI/5 and approaches something less than PI
                        // as count gets large.  Unfortunately, self-loops
                        // again have to be handled specially.
                        double angle;

                        if (headPort.getContainer() != tailPort.getContainer()) {
                            angle = (Math.PI / 5.0)
                                    + (1.5 * Math.atan(0.3 * count));
                        } else {
                            angle = (Math.PI / 3.0)
                                    - (0.75 * Math.atan(0.3 * count));
                        }

                        // Create the new relation.
                        // Note that we specify no class so that we use the
                        // container's factory method when this gets parsed
                        moml.append("<relation name=\"" + relationName
                                + "\"><property name=\"exitAngle\" value=\""
                                + angle + "\"/></relation>\n");
                        moml.append("<link port=\""
                                + tailPort.getName(ptolemyModel)
                                + "\" relation=\"" + relationName + "\"/>\n");
                    }

                    moml.append("<link port=\""
                            + headPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");

                    // Record moml so that we can blow away these
                    // links in case we can't create them
                    failmoml.append("<unlink port=\""
                            + headPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");

                    if (linkRelation == null) {
                        failmoml.append("<unlink port=\""
                                + tailPort.getName(ptolemyModel)
                                + "\" relation=\"" + relationName + "\"/>\n");
                        failmoml.append("<deleteRelation name=\""
                                + relationName + "\"/>\n");
                    }

View Full Code Here

                if (head instanceof State && tail instanceof State) {
                    // When we connect two states, we actually connect the
                    // appropriate ports.
                    State headState = (State) head;
                    State tailState = (State) tail;
                    ComponentPort headPort = headState.incomingPort;
                    ComponentPort tailPort = tailState.outgoingPort;
                    NamedObj ptolemyModel = getPtolemyModel();

                    // If the context is not the entity that we're editing,
                    // then we need to set the context correctly.
                    if (ptolemyModel != container) {
                        String contextString = "<entity name=\""
                                + ptolemyModel.getName(container) + "\">\n";
                        moml.append(contextString);
                        failmoml.append(contextString);
                    }

                    boolean createdNewRelation = false;
                    String relationName = null;

                    if (linkRelation != null) {
                        // Pre-existing relation. Use it.
                        relationName = linkRelation.getName(ptolemyModel);
                    } else {
                        createdNewRelation = true;

                        // Linking two ports with a new relation.
                        relationName = ptolemyModel.uniqueName("relation");

                        // Note that we specify no class so that we use the
                        // container's factory method when this gets parsed
                        moml.append("<relation name=\"" + relationName
                                + "\"/>\n");
                        moml.append("<link port=\""
                                + headPort.getName(ptolemyModel)
                                + "\" relation=\"" + relationName + "\"/>\n");
                    }

                    moml.append("<link port=\""
                            + tailPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");

                    // Record moml so that we can blow away these
                    // links in case we can't create them
                    failmoml.append("<unlink port=\""
                            + tailPort.getName(ptolemyModel) + "\" relation=\""
                            + relationName + "\"/>\n");

                    if (linkRelation == null) {
                        failmoml.append("<unlink port=\""
                                + headPort.getName(ptolemyModel)
View Full Code Here

         */
        private String _unlinkHead(NamedObj container, NamedObj linkHead,
                Relation relation) {
            NamedObj head = (NamedObj) getSemanticObject(linkHead);
            State headState = (State) head;
            ComponentPort headPort = headState.incomingPort;
            return "<unlink port=\"" + headPort.getName(container)
                    + "\" relation=\"" + relation.getName(container) + "\"/>\n";
        }
View Full Code Here

         */
        private String _unlinkTail(NamedObj container, NamedObj linkTail,
                Relation relation) {
            NamedObj tail = (NamedObj) getSemanticObject(linkTail);
            State tailState = (State) tail;
            ComponentPort tailPort = tailState.outgoingPort;
            return "<unlink port=\"" + tailPort.getName(container)
                    + "\" relation=\"" + relation.getName(container) + "\"/>\n";
        }
View Full Code Here

                }
            }

            if (replacement instanceof ComponentPort
                    && host instanceof ComponentPort) {
                ComponentPort replacementComponentPort = (ComponentPort) replacement;
                ComponentPort hostComponentPort = (ComponentPort) host;
                for (Object replacementRelationObject : replacementComponentPort
                        .insideRelationList()) {
                    Relation replacementRelation = (Relation) replacementRelationObject;
                    Relation hostRelation = (Relation) _replacementToHost
                            .get(replacementRelation);
                    if (!hostComponentPort.insideRelationList().contains(
                            hostRelation)) {
                        // There is no link between hostPort and hostRelation,
                        // so create a new link.
                        NamedObj hostContainer = hostRelation.getContainer();
                        String moml = _getLinkMoML(host, hostRelation);
View Full Code Here

                    false, false, true, true);

            // Record the connections to the composite entity's ports.
            Map<Port, List<Object>> portLinks = new HashMap<Port, List<Object>>();
            for (Object portObject : entity.portList()) {
                ComponentPort port = (ComponentPort) portObject;
                List<Object> linkedRelations = new LinkedList<Object>();
                linkedRelations.addAll((Collection<?>) port
                        .linkedRelationList());
                linkedRelations.addAll((Collection<?>) port
                        .insideRelationList());
                portLinks.put(port, linkedRelations);
            }

            // Remove the composite entity here because when the objects are
View Full Code Here

            Iterator states = entityList().iterator();

            while (states.hasNext()) {
                State state = (State) states.next();

                ComponentPort inPort = state.incomingPort;
                List transitionList = inPort.linkedRelationList();
                InterfaceAutomatonTransition incomingTransition = null;

                if (transitionList.size() != 1) {
                    continue;
                }

                // just one incoming transition, check if it's internal
                incomingTransition = (InterfaceAutomatonTransition) transitionList
                        .get(0);

                if (incomingTransition.getType() != InterfaceAutomatonTransition._INTERNAL_TRANSITION) {
                    continue;
                }

                ComponentPort outPort = state.outgoingPort;
                transitionList = outPort.linkedRelationList();

                InterfaceAutomatonTransition outgoingTransition = null;

                if (transitionList.size() != 1) {
                    continue;
View Full Code Here

TOP

Related Classes of ptolemy.kernel.ComponentPort

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.