Package ptolemy.kernel

Examples of ptolemy.kernel.Entity


        LinkedList workList = new LinkedList(_variableToChangeContext.keySet());

        while (!workList.isEmpty()) {
            Variable variable = (Variable) workList.removeFirst();
            Node node = _dependencyGraph.node(variable);
            Entity changeContext = (Entity) _variableToChangeContext
                    .get(variable);

            for (Iterator outputEdges = _dependencyGraph.outputEdges(node)
                    .iterator(); outputEdges.hasNext();) {
                Node sinkNode = ((Edge) outputEdges.next()).sink();
View Full Code Here


    // be at least the given change context.
    // return true if a change occurred
    private final boolean _updateChangeContext(Variable variable,
            Entity changeContext) {
        if (_variableToChangeContext.keySet().contains(variable)) {
            Entity oldChangeContext = (Entity) _variableToChangeContext
                    .get(variable);

            // System.out.println("variable = " + variable);
            // System.out.println("oldChangeContext = " + oldChangeContext);
            // System.out.println("updatedChangeContext = " + changeContext);
            Entity newChangeContext = _computeBound(changeContext,
                    oldChangeContext);

            // System.out.println("newChangeContext = " + newChangeContext);
            if (newChangeContext != oldChangeContext) {
                _variableToChangeContext.put(variable, newChangeContext);
View Full Code Here

        //hscInV.link(rSubOutV);
        //hscInR.link(rSubOutR);
        Iterator entities = sub.entityList().iterator();

        while (entities.hasNext()) {
            Entity ent = (Entity) entities.next();
            Port p = ent.getPort("inputPx");

            if (p != null) {
                p.link(rSubPx);
            }

            p = ent.getPort("inputDPx");

            if (p != null) {
                p.link(rSubDPx);
            }

            p = ent.getPort("inputDDPx");

            if (p != null) {
                p.link(rSubDDPx);
            }

            p = ent.getPort("inputD3Px");

            if (p != null) {
                p.link(rSubD3Px);
            }

            p = ent.getPort("inputD4Px");

            if (p != null) {
                p.link(rSubD4Px);
            }

            p = ent.getPort("inputPz");

            if (p != null) {
                p.link(rSubPz);
            }

            p = ent.getPort("inputDPz");

            if (p != null) {
                p.link(rSubDPz);
            }

            p = ent.getPort("inputDDPz");

            if (p != null) {
                p.link(rSubDDPz);
            }

            p = ent.getPort("inputD3Pz");

            if (p != null) {
                p.link(rSubD3Pz);
            }

            p = ent.getPort("inputD4Pz");

            if (p != null) {
                p.link(rSubD4Pz);
            }

            p = ent.getPort("outputVx");

            if (p != null) {
                p.link(rSubOutVx);
            }

            p = ent.getPort("outputVz");

            if (p != null) {
                p.link(rSubOutVz);
            }

            p = ent.getPort("outputV");

            if (p != null) {
                p.link(rSubOutV);
            }

            p = ent.getPort("outputR");

            if (p != null) {
                p.link(rSubOutR);
            }
        }
View Full Code Here

        Set set = new HashSet();

        if (model instanceof CompositeEntity) {
            for (Iterator entities = ((CompositeEntity) model).entityList()
                    .iterator(); entities.hasNext();) {
                Entity entity = (Entity) entities.next();
                set.addAll(_freeVariables(entity));
            }
        }

        // Next, compute the set of variable names defined in this container.
View Full Code Here

        Collection<Object> collection = new CombinedCollection<Object>();
        if (includeAttributes) {
            collection.addAll((Collection<?>) object.attributeList());
        }
        if (includePorts && object instanceof Entity) {
            Entity entity = (Entity) object;
            collection.addAll((Collection<?>) entity.portList());
        }
        if (object instanceof CompositeEntity) {
            CompositeEntity entity = (CompositeEntity) object;
            if (includeEntities) {
                collection.addAll((Collection<?>) entity.entityList());
            }
            if (includeRelations) {
                collection.addAll((Collection<?>) entity.relationList());
            }
        }
        return collection;
    }
View Full Code Here

            query.addLine("Name", "Name", defaultName);

            // See whether the configuration offers transition refinements.
            Configuration configuration = ((FSMGraphController) getController())
                    .getConfiguration();
            Entity refinements = configuration
                    .getEntity("_transitionRefinements");

            // Default choices.
            String[] choiceClasses = { "ptolemy.domains.fsm.modal.TransitionRefinement" };
            String[] choiceNames = { "Default Refinement" };

            // Check the configuration to see whether the default is overridden.
            if (refinements instanceof CompositeEntity) {
                // There is a specification.
                List refinementList = ((CompositeEntity) refinements)
                        .entityList();
                choiceNames = new String[refinementList.size()];
                choiceClasses = new String[refinementList.size()];

                Iterator iterator = refinementList.iterator();
                int count = 0;

                while (iterator.hasNext()) {
                    Entity entity = (Entity) iterator.next();
                    choiceNames[count] = entity.getName();
                    choiceClasses[count++] = entity.getClass().getName();
                }
            }

            query
                    .addChoice("Class", "Class", choiceNames, choiceNames[0],
                            true);

            // FIXME: Need a frame owner for first arg.
            // Perhaps calling getController(), which returns a GraphController
            // will be a good start.
            ComponentDialog dialog = new ComponentDialog(null,
                    "Specify Refinement", query);

            if (!dialog.buttonPressed().equals("OK")) {
                return;
            }

            final String newName = query.getStringValue("Name");

            if (container.getEntity(newName) != null) {
                MessageHandler.error("There is already a refinement with name "
                        + newName + ".");
                return;
            }

            int choiceIndex = query.getIntValue("Class");
            String newClass = choiceClasses[choiceIndex];

            String currentRefinements = transition.refinementName
                    .getExpression();

            if ((currentRefinements == null) || currentRefinements.equals("")) {
                currentRefinements = newName;
            } else {
                currentRefinements = currentRefinements.trim() + ", " + newName;
            }

            String moml;

            // The MoML we create depends on whether the configuration
            // specified a set of prototype refinements.
            if (refinements instanceof CompositeEntity) {
                String choiceName = choiceNames[choiceIndex];
                Entity template = ((CompositeEntity) refinements)
                        .getEntity(choiceName);
                String templateDescription = template.exportMoML(newName);
                moml = "<group>" + templateDescription + "<relation name=\""
                        + transition.getName(container)
                        + "\"><property name=\"refinementName\" value=\""
                        + currentRefinements + "\"/></relation></group>";
            } else {
                moml = "<group><entity name=\"" + newName + "\" class=\""
                        + newClass + "\"/>" + "<relation name=\""
                        + transition.getName(container)
                        + "\"><property name=\"refinementName\" value=\""
                        + currentRefinements + "\"/></relation></group>";
            }

            MoMLChangeRequest change = new MoMLChangeRequest(this, container,
                    moml) {
                protected void _execute() throws Exception {
                    super._execute();

                    // Mirror the ports of the container in the refinement.
                    // Note that this is done here rather than as part of
                    // the MoML because we have set protected variables
                    // in the refinement to prevent it from trying to again
                    // mirror the changes in the container.
                    Entity entity = container.getEntity(newName);

                    // Get the initial port configuration from the container.
                    Iterator ports = container.portList().iterator();

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

                        try {
                            // NOTE: This is awkward.
                            if (entity instanceof Refinement) {
                                ((Refinement) entity).setMirrorDisable(true);
                            } else if (entity instanceof ModalController) {
                                ((ModalController) entity)
                                        .setMirrorDisable(true);
                            }

                            Port newPort = entity.newPort(port.getName());

                            if (newPort instanceof RefinementPort
                                    && port instanceof IOPort) {
                                try {
                                    ((RefinementPort) newPort)
View Full Code Here

    /** Get the model directory.
     *  @return The model directory, or null if there isn't one.
     */
    public ModelDirectory getDirectory() {
        Entity directory = getEntity(_DIRECTORY_NAME);

        if (directory instanceof ModelDirectory) {
            return (ModelDirectory) directory;
        }

View Full Code Here

     *  that is an effigy for the specified model.
     *  @param model The Ptolemy model.
     *  @return The effigy for the model, or null if none is found.
     */
    public PtolemyEffigy getEffigy(NamedObj model) {
        Entity directory = getEntity(_DIRECTORY_NAME);

        if (directory instanceof ModelDirectory) {
            return _findEffigyForModel((ModelDirectory) directory, model);
        } else {
            return null;
View Full Code Here

     *  DialogTableau.
     * @param entity Entity that test is performed on.,
     * @return true/false True if entity is associated with this DialogTableau.
     */
    public boolean hasTarget(Entity entity) {
        Entity target = getTarget();

        if ((target != null) && (target == entity)) {
            return true;
        }

View Full Code Here

                RefType.v(PtolemyUtilities.entityClass));
        body.getLocals().add(entityLocal);

        for (Iterator entities = composite.entityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();
            System.out.println("ShallowModelTransformer: entity: " + entity);

            Local local;

            // If we are doing shallow, then use the base actor
            // classes.  Note that the entity might actually be
            // a MoML class (like Sinewave).
            String className = entity.getClass().getName();
            Scene.v().loadClassAndSupport(className);

            if (createdSet.contains(entity.getFullName())) {
                // Get a reference to the previously created entity.
                local = Jimple.v().newLocal("entity",
                        PtolemyUtilities.componentEntityType);
                body.getLocals().add(local);
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                entityLocal,
                                Jimple.v().newVirtualInvokeExpr(
                                        containerLocal,
                                        PtolemyUtilities.getEntityMethod
                                                .makeRef(),
                                        StringConstant.v(entity
                                                .getName(container)))));

                // and then cast
                body.getUnits().add(
                        Jimple.v().newAssignStmt(
                                local,
                                Jimple.v().newCastExpr(entityLocal,
                                        RefType.v(className))));
            } else {
                // Create a new local variable.
                // The name of the local is determined automatically.
                // The name of the NamedObj is the same as in the model.
                // (Note that this might not be a valid Java identifier.)
                local = PtolemyUtilities.createNamedObjAndLocal(body,
                        className, thisLocal, entity.getName());

                Entity classEntity = (Entity) _findDeferredInstance(entity);

                if (!(entity instanceof CompositeEntity)
                        || className.equals(entity.getClassName())) {
                    // If the entity is NOT a moml class....
                    // Then record the things inside the master as things
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Entity

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.