Package ptolemy.actor

Examples of ptolemy.actor.CompositeActor


     @return true if the expression was successfully sent, false if the
     *  port is not connected or not found.
     */
    public boolean sendToPort(String portName, String expression) {
        try {
            CompositeActor model = (CompositeActor) getContainer();
            TypedIOPort port = (TypedIOPort) model.getPort(portName);
            if (port != null) {
                if (port.getWidth() > 0) {
                    if (port.getType() == BaseType.BOOLEAN) {
                        port.send(0, new BooleanToken(expression));
                        return true;
View Full Code Here


     @param minimumBufferSizes A map from relation
     *  to the minimum possible buffer size of that relation.
     */
    protected void _saveBufferSizes(final Map minimumBufferSizes) {
        Director director = (Director) getContainer();
        final CompositeActor container = (CompositeActor) director
                .getContainer();

        // FIXME: These buffer sizes should be properties of input ports,
        // not properties of relations.
        ChangeRequest request = new ChangeRequest(this, "Record buffer sizes") {
            protected void _execute() throws KernelException {
                Iterator relations = container.relationList().iterator();

                while (relations.hasNext()) {
                    Relation relation = (Relation) relations.next();
                    Object bufferSizeObject = minimumBufferSizes.get(relation);

                    if (bufferSizeObject instanceof Integer) {
                        int bufferSize = ((Integer) bufferSizeObject)
                                .intValue();
                        DFUtilities.setOrCreate(relation, "bufferSize",
                                bufferSize);

                        if (_debugging) {
                            _debug("Adding bufferSize parameter to "
                                    + relation.getName() + " with value "
                                    + bufferSize);
                        }
                    } else if (bufferSizeObject instanceof String) {
                        String bufferSizeExpression = (String) bufferSizeObject;
                        DFUtilities.setOrCreate(relation, "bufferSize", "\""
                                + bufferSizeExpression + "\"");

                        if (_debugging) {
                            _debug("Adding bufferSize parameter to "
                                    + relation.getName() + " with expression "
                                    + bufferSizeExpression);
                        }
                    } else if (bufferSizeObject == null) {
                    } else {
                        throw new InternalErrorException(
                                "Invalid value found "
                                        + "in buffer size map.\nValue is of type "
                                        + bufferSizeObject.getClass().getName()
                                        + ".\nIt should be of type Integer or String.\n");
                    }
                }
            }
        };

        // Indicate that the change is non-persistent, so that
        // the UI doesn't prompt to save.
        request.setPersistent(false);
        container.requestChange(request);
    }
View Full Code Here

     @param model The model for which to generate code.
     *  @return A String representation of the nesC code.
     */
    private String _generateCode(CompositeActor model)
            throws IllegalActionException {
        CompositeActor container = (CompositeActor) getContainer();

        //NamedObj toplevel = _toplevelNC();
        _CodeString generatedCode = new _CodeString();

        String containerName = _sanitizedFullName(model);
View Full Code Here

    /** Get the current model time and return the long value.
     *  @return The model time as a long value, or 0 if the model time
     *  is null.
     */
    private long _getModelTimeAsLongValue() {
        CompositeActor container = (CompositeActor) getContainer();

        // Get the executive director.  If there is none, use this instead.
        Director director = container.getExecutiveDirector();
        if (director == null) {
            director = this;
        }

        // Get the current model time.
View Full Code Here

            // input or output and not both.
            List sourcePortList = port.insidePortList();

            //FIXME: can the list be empty?

            CompositeActor container = (CompositeActor) getContainer();

            if ((sourcePortList != null)
                    && !(container instanceof PtinyOSCompositeActor)) {
                // FIXME: test this code
                for (int i = 0; i < sourcePortList.size(); i++) {
View Full Code Here

     *   tokenInitProduction.
     */
    protected void _saveContainerRates(Map externalRates)
            throws NotSchedulableException, IllegalActionException {
        Director director = (Director) getContainer();
        CompositeActor container = (CompositeActor) director.getContainer();
        Iterator ports = container.portList().iterator();

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

            if (_debugging && VERBOSE) {
View Full Code Here

     *  to the number of times it will fire in one execution of the schedule.
     *  @param entityToFiringsPerIteration A map from actor to firing count.
     */
    protected void _saveFiringCounts(final Map entityToFiringsPerIteration) {
        Director director = (Director) getContainer();
        final CompositeActor container = (CompositeActor) director
                .getContainer();

        ChangeRequest request = new ChangeRequest(this,
                "Record firings per iteration") {
            protected void _execute() throws KernelException {
                Iterator entities = entityToFiringsPerIteration.keySet()
                        .iterator();

                while (entities.hasNext()) {
                    Entity entity = (Entity) entities.next();
                    int firingCount = ((Integer) entityToFiringsPerIteration
                            .get(entity)).intValue();
                    DFUtilities.setOrCreate(entity, "firingsPerIteration",
                            firingCount);

                    if (_debugging) {
                        _debug("Adding firingsPerIteration parameter to "
                                + entity.getName() + " with value "
                                + firingCount);
                    }
                }
            }
        };

        // Indicate that the change is non-persistent, so that
        // the UI doesn't prompt to save.
        request.setPersistent(false);
        container.requestChange(request);
    }
View Full Code Here

    public void _createView() {
        super._createView();

        try {
            // Find out how many iterations the director expects to run for.
            CompositeActor toplevel = (CompositeActor) _toplevel;
            SDFDirector director = (SDFDirector) toplevel.getDirector();
            int iterations = ((IntToken) (director.iterations.getToken()))
                    .intValue();

            _sketchedSource = (SketchedSource) toplevel
                    .getEntity("SketchedSource");

            // Note: The order of the following is important.
            // First, specify how long the sketched plot should be.
            _sketchedSource.length.setToken(new IntToken(iterations));
View Full Code Here

            // it in copernicus.kernel.Copernicus, so we
            // the values inside the GeneratorAttribute inside _model
            // are likely to be wrong.
            MoMLParser parser = new MoMLParser();

            CompositeActor toplevel;

            // Get the old filters, save them, add our own
            // filters, use them, remove our filters,
            // and then readd the old filters in the finally clause.
            // We do something
            // similar in GeneratorAttribute.updateModelAttributes()
            List oldFilters = MoMLParser.getMoMLFilters();
            MoMLParser.setMoMLFilters(null);

            try {
                // Handle Backward Compatibility.
                MoMLParser.addMoMLFilters(BackwardCompatibility.allFilters());

                // We don't call parseFile() here because it calls gets
                // the user.dir property.
                toplevel = (CompositeActor) parser.parse(null, new File(
                        _generatorAttributeFileName).toURI().toURL());
            } finally {
                // Restore the saved momlfilters
                MoMLParser.setMoMLFilters(oldFilters);
            }

            generatorAttribute = (GeneratorAttribute) toplevel.getAttribute(
                    Copernicus.GENERATOR_NAME, GeneratorAttribute.class);

            if (generatorAttribute == null) {
                System.out.println("MakefileWriter: Warning, parsing '"
                        + _generatorAttributeFileName
                        + "' did not contain an attribute " + " called '"
                        + Copernicus.GENERATOR_NAME + "'"
                        + toplevel.exportMoML());
                generatorAttribute = new GeneratorAttribute(toplevel,
                        Copernicus.GENERATOR_NAME);
            }
        } catch (Exception ex) {
            throw new InternalErrorException(_model, ex, "Problem getting the"
View Full Code Here

    /** Return a list of all the input ports contained by the
     *  deeply contained entities of the container of this director.
     *  @return The list of input ports.
     */
    private List _getInputPortList() {
        CompositeActor container = (CompositeActor) getContainer()
                .getContainer();
        List actors = container.deepEntityList();
        Iterator actorIterator = actors.iterator();
        List inputPortList = new LinkedList();

        while (actorIterator.hasNext()) {
            Actor containedActor = (Actor) actorIterator.next();
View Full Code Here

TOP

Related Classes of ptolemy.actor.CompositeActor

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.