Package ptolemy.actor

Examples of ptolemy.actor.CompositeActor


     @exception IllegalActionException If the transferOutputs(Port)
     *   method throws it.
     */
    private void _transferOutputsToEnvironment() throws IllegalActionException {
        // If there are no output ports, this method does nothing.
        CompositeActor container = (CompositeActor) getContainer();
        Iterator outports = container.outputPortList().iterator();
        while (outports.hasNext() && !_stopRequested) {
            IOPort p = (IOPort) outports.next();
            super.transferOutputs(p);
        }
    }
View Full Code Here


         *  exists with the given name, but cannot be evaluated.
         */
        public ptolemy.data.Token get(String name)
                throws IllegalActionException {
            PSDFDirector director = (PSDFDirector) getContainer();
            CompositeActor reference = (CompositeActor) director.getContainer();
            Variable result = getScopedVariable(null, reference, name);

            if (result != null) {
                return result.getToken();
            } else {
View Full Code Here

         *  exists with the given name, but cannot be evaluated.
         */
        public ptolemy.data.type.Type getType(String name)
                throws IllegalActionException {
            PSDFDirector director = (PSDFDirector) getContainer();
            CompositeActor reference = (CompositeActor) director.getContainer();
            Variable result = getScopedVariable(null, reference, name);

            if (result != null) {
                return result.getType();
            } else {
View Full Code Here

         *  exists with the given name, but cannot be evaluated.
         */
        public ptolemy.graph.InequalityTerm getTypeTerm(String name)
                throws IllegalActionException {
            PSDFDirector director = (PSDFDirector) getContainer();
            CompositeActor reference = (CompositeActor) director.getContainer();
            Variable result = getScopedVariable(null, reference, name);

            if (result != null) {
                return result.getTypeTerm();
            } else {
View Full Code Here

     */
    protected void _constructDetailedDependencyGraph() {
        super._constructDetailedDependencyGraph();
        // Note: cannot call getDetailedDependencyGraph()! because the
        // _version is not updated yet and it will result in an infinite loop.
        CompositeActor actor = (CompositeActor) getContainer();
        if (actor instanceof EnabledComposite) {
            IOPort enable = ((EnabledComposite) actor).enable;
            Iterator outputs = ((Actor) getContainer()).outputPortList()
                    .listIterator();
            while (outputs.hasNext()) {
View Full Code Here

     *  transition to the manager.
     *  @exception IllegalActionException If there is no controller,
     *   or if the current state has no or more than one refinement.
     */
    public void fire() throws IllegalActionException {
        CompositeActor container = (CompositeActor) getContainer();
        FSMActor controller = getController();
        controller.setNewIteration(_sendRequest);
        _readInputs();

        State currentState = controller.currentState();

        Actor[] actors = currentState.getRefinement();

        // NOTE: Paranoid coding.
        if ((actors == null) || (actors.length != 1)) {
            throw new IllegalActionException(this,
                    "Current state is required to have exactly one refinement: "
                            + currentState.getName());
        }

        if (!_stopRequested) {
            if (actors[0].prefire()) {
                if (_debugging) {
                    _debug(getFullName(), " fire refinement",
                            ((ptolemy.kernel.util.NamedObj) actors[0])
                                    .getName());
                }

                actors[0].fire();
                _refinementPostfire = actors[0].postfire();
            }
        }

        _readOutputsFromRefinement();

        if (_sendRequest) {
            ChangeRequest request = new ChangeRequest(this,
                    "choose a transition") {
                protected void _execute() throws KernelException,
                        IllegalActionException {
                    FSMActor controller = getController();
                    State currentState = controller.currentState();
                    chooseNextNonTransientState(currentState);
                }
            };

            request.setPersistent(false);
            container.requestChange(request);
        }
    }
View Full Code Here

     *   returns true.
     *  @exception IllegalActionException If a refinement throws it,
     *   if there is no controller.
     */
    public boolean postfire() throws IllegalActionException {
        CompositeActor container = (CompositeActor) getContainer();

        if (_sendRequest) {
            _sendRequest = false;

            ChangeRequest request = new ChangeRequest(this, "make a transition") {
                protected void _execute() throws KernelException {
                    _sendRequest = true;

                    // The super.postfire() method is called here.
                    makeStateTransition();
                }
            };

            request.setPersistent(false);
            container.requestChange(request);
        }

        return _refinementPostfire;
    }
View Full Code Here

     */
    public void enqueueEvent(String newTime) {
        try {
            // Assumes that we already checked in preinitialize() that the
            // container is a CompositeActor.
            CompositeActor container = (CompositeActor) getContainer();

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

            if (director == null) {
                director = this;
            }

View Full Code Here

            if (_debugging) {
                _debug("Called getCharParameterValue with " + parameter
                        + " as argument.");
            }

            CompositeActor model = (CompositeActor) getContainer();
            IOPort port = (IOPort) model.getPort(parameter);
            if (port != null) {
                if (port instanceof ParameterPort) {
                    Token token = ((ParameterPort) port).getParameter()
                        .getToken();
                    if (token != null) {
View Full Code Here

                        "Could not create directory " + directory);
            }
        }

        // Generate the code as a string.
        CompositeActor container = (CompositeActor) getContainer();
        String code = _generateCode(container);

        // FIXME: test this code to make sure it works even if this
        // director is embedded more deeply.

        //Create file name relative to the toplevel NCCompositeActor.
        NamedObj toplevel = _toplevelNC(); //container.toplevel();
        String filename = _sanitizedFullName(toplevel);
        if (container != toplevel) {
            filename = filename + "_" + container.getName(toplevel);
            filename = StringUtilities.sanitizeName(filename);
        }

        // Open file for the generated nesC code.
        File writeFile = new File(directory, filename + ".nc");

        if (_confirmOverwrite(writeFile)) {
            // Write the generated code to the file.
            FileWriter writer = null;
            try {
                writer = new FileWriter(writeFile);
                writer.write(code);
            } catch (IOException ex) {
                throw new IllegalActionException(this, ex,
                        "Failed to open file for writing.");
            } finally {
                try {
                    writer.close();
                } catch (Exception ex) {
                    throw new IllegalActionException(this, ex,
                            "Failed to close file.");
                }
            }
        }

        // Descend recursively into contained composites.
        Iterator entities = container.entityList(CompositeActor.class)
                .iterator();

        while (entities.hasNext()) {
            CompositeActor contained = (CompositeActor) entities.next();
            contained.preinitialize();
        }

        // If this is the toplevel PtinyOSDirector, generate makefile
        // and compile the generated code.
        if (_isTopLevelNC()) {
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.