Package ptolemy.kernel

Examples of ptolemy.kernel.ComponentEntity


                    // If the entity does not contain a location, then create one.
                    Iterator classes = ((CompositeEntity) composite)
                            .classDefinitionList().iterator();

                    while (classes.hasNext()) {
                        ComponentEntity entity = (ComponentEntity) classes
                                .next();
                        nodes.add(_getLocation(entity));
                    }

                    // Add a graph node for every entity.
                    // The node is actually the location contained by the entity.
                    // If the entity does not contain a location, then create one.
                    Iterator entities = ((CompositeEntity) composite)
                            .entityList().iterator();

                    while (entities.hasNext()) {
                        ComponentEntity entity = (ComponentEntity) entities
                                .next();
                        nodes.add(_getLocation(entity));
                    }
                }
View Full Code Here


    // Note that we have to carefully handle transparent hierarchy.
    private static void _linksOnPortsContainedByContainedEntities(
            JimpleBody body, CompositeActor composite) {
        for (Iterator entities = composite.deepEntityList().iterator(); entities
                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                ComponentPort port = (ComponentPort) ports.next();

                Local portLocal;

                // If we already have a local reference to the port
View Full Code Here

                                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");
View Full Code Here

                    // MoML description for actor declaration.
                    String description = "<entity name =\"" + uniqueName
                            + "\" class =\"" + actor + "\"/>";
                    momlParser.parse(null, description);

                    ComponentEntity entity = null;
                    if (_actor != null) {
                        entity = _actor.getEntity(uniqueName);
                    }
                    if (_actor == null || entity == null) {
                        throw new PtalonRuntimeException(
                                "Could not create new actor.");
                    }

                    for (int i = 1; i < parsedExpression.length; i = i + 2) {
                        String lhs = parsedExpression[i];
                        String rhs = parsedExpression[i + 1];
                        if (rhs.startsWith("<")) {
                            rhs = rhs.substring(1, rhs.length() - 2);
                        }
                        Parameter param = (Parameter) entity.getAttribute(lhs);
                        // Use setToken(String) rather than
                        // setExpression(String) because this forces
                        // the parameter to be validated
                        // (attributeChanged() is called and value
                        // dependents are notified).
View Full Code Here

        ArrayList portAssignments = new ArrayList();
        ArrayList parameterAssignments = new ArrayList();
        List entityList = ((CompositeEntity) getContainer()).entityList();

        for (Iterator i = entityList.iterator(); i.hasNext();) {
            ComponentEntity entity = (ComponentEntity) i.next();

            // Skip the type test actor itself.
            if (entity.equals(this)) {
                continue;
            }

            ArrayList portNames = new ArrayList();
            ArrayList portTypes = new ArrayList();

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                TypedIOPort port = (TypedIOPort) ports.next();
                portNames.add(port.getName());
                portTypes.add(new StringToken(port.getType().toString()));
            }

            if (portNames.size() > 0) {
                portActorNameList.add(entity.getName());
                portAssignments.add(new RecordToken((String[]) portNames
                        .toArray(new String[portNames.size()]),
                        (Token[]) portTypes
                                .toArray(new Token[portTypes.size()])));
            }

            ArrayList paramNames = new ArrayList();
            ArrayList paramTypes = new ArrayList();

            for (Iterator params = entity.attributeList(Parameter.class)
                    .iterator(); params.hasNext();) {
                Parameter param = (Parameter) params.next();
                paramNames.add(param.getName());
                paramTypes.add(new StringToken(param.getType().toString()));
            }

            if (paramNames.size() > 0) {
                parameterActorNameList.add(entity.getName());
                parameterAssignments.add(new RecordToken((String[]) paramNames
                        .toArray(new String[paramNames.size()]),
                        (Token[]) paramTypes.toArray(new Token[paramTypes
                                .size()])));
            }
View Full Code Here

        Director director = model.getDirector();

        // Loop over all the model instance classes.
        for (Iterator entities = model.deepEntityList().iterator(); entities
                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();
            String className = ModelTransformer.getInstanceClassName(entity,
                    _options);
            SootClass entityClass = Scene.v().loadClassAndSupport(className);

            // recurse.
View Full Code Here

        }

        // Loop over all the model instance classes.
        for (Iterator entities = model.deepEntityList().iterator(); entities
                .hasNext();) {
            ComponentEntity entity = (ComponentEntity) entities.next();
            String className = ModelTransformer.getInstanceClassName(entity,
                    _options);
            SootClass entityClass = Scene.v().loadClassAndSupport(className);

            // Loop through all the methods and replace calls on ports.
View Full Code Here

                specificationURL, specificationURL);

        // If the toplevel model is a configuration containing a directory,
        // then create an effigy for the configuration itself, and put it
        // in the directory.
        ComponentEntity directory = configuration.getEntity("directory");

        if (directory instanceof ModelDirectory) {
            PtolemyEffigy effigy = null;
            try {
                effigy = new PtolemyEffigy((ModelDirectory) directory,
View Full Code Here

     * @param nodes
     *            The set of nodes(ComponentEntities).
     */
    public Bindings(Vector nodes) {
        for (int i = 0; i < nodes.size(); i++) {
            ComponentEntity actor = (ComponentEntity) (nodes.elementAt(i));
            Iterator iter = actor.portList().iterator();

            while (iter.hasNext()) {
                IOPort actorPort = (IOPort) iter.next();
                String varLabel = actor.getName() + "." + actorPort.getName();
                put(varLabel, null);
            }
        }
    }
View Full Code Here

        this();
        _model = model;
        _bindings = new Bindings(entities);

        for (int i = 0; i < entities.size(); i++) {
            ComponentEntity componentEntity = (ComponentEntity) (entities
                    .elementAt(i));
            Vector actorConstraints = new Vector();
            List unitsAttrs = componentEntity
                    .attributeList(ptolemy.data.unit.UnitAttribute.class);

            for (int j = 0; j < unitsAttrs.size(); j++) {
                UnitAttribute attr = (UnitAttribute) (unitsAttrs.get(j));

                if (attr.getName().equals("_unitConstraints")) {
                    actorConstraints.addAll(attr.getUnitConstraints()
                            .getConstraints());
                }
            }

            for (int j = 0; j < actorConstraints.size(); j++) {
                UnitEquation uEquation = ((UnitEquation) (actorConstraints
                        .elementAt(j))).copy();
                _equationVisitor.expand(uEquation, componentEntity);
                uEquation.setSource(componentEntity);
                addConstraint(uEquation);
            }

            Iterator iter = componentEntity.portList().iterator();

            while (iter.hasNext()) {
                IOPort actorPort = (IOPort) iter.next();
                UnitExpr rhsExpr = null;
                UnitAttribute ua = (UnitAttribute) (actorPort
View Full Code Here

TOP

Related Classes of ptolemy.kernel.ComponentEntity

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.