Package ptolemy.actor

Examples of ptolemy.actor.Actor


     (port).
     *  @return The CSPDirector controlling this model.
     */
    protected CSPDirector _getDirector() {
        try {
            Actor container = (Actor) getContainer().getContainer();
            if (isInsideBoundary()) {
                return (CSPDirector) container.getDirector();
            } else {
                return (CSPDirector) container.getExecutiveDirector();
            }
        } catch (NullPointerException ex) {
            // If a thread has a reference to a receiver with no director it
            // is an error so terminate the process.
            throw new TerminateProcessException("CSPReceiver: trying to "
View Full Code Here


    public void setContainer(IOPort port) throws IllegalActionException {
        super.setContainer(port);
        if (port == null) {
            _director = null;
        } else {
            Actor actor = (Actor) port.getContainer();
            Director director;

            // For a composite actor,
            // the receiver type of an input port is decided by
            // the executive director.
            // While the receiver type of an output is decided by the director.
            // NOTE: getExecutiveDirector() and getDirector() yield the same
            // result for actors that do not contain directors.
            if (port.isInput()) {
                director = actor.getExecutiveDirector();
            } else {
                director = actor.getDirector();
            }

            if (!(director instanceof PNDirector)) {
                throw new IllegalActionException(port,
                        "Cannot use an instance of PNQueueReceiver "
View Full Code Here

        // for the whole model. We have to make sure there is a manager,
        // and then preinitialize and resolve types.
        if (isTopLevel()) {

            // If necessary, create a manager.
            Actor container = ((Actor) getContainer());
            Manager manager = container.getManager();

            if (manager == null) {
                CompositeActor toplevel = (CompositeActor) ((NamedObj) container)
                        .toplevel();
                manager = new Manager(toplevel.workspace(), "Manager");
View Full Code Here

            code.append(_createOffsetVariablesIfNeeded(outputPort));
        }

        Iterator actors = container.deepEntityList().iterator();
        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();
            CodeGeneratorHelper actorHelper = (CodeGeneratorHelper) _getHelper((NamedObj) actor);
            int[][] rates = actorHelper.getRates();
            // If a refinement has only one configuration, then there is no
            // need to use variables.
            if (!(actor instanceof Refinement && rates == null)) {
                Iterator inputPorts = actor.inputPortList().iterator();
                while (inputPorts.hasNext()) {
                    IOPort inputPort = (IOPort) inputPorts.next();
                    code.append(_createOffsetVariablesIfNeeded(inputPort));
                }
            }
View Full Code Here

        Iterator embeddedActorsIterator = embeddedActors.iterator();

        // iterate all embedded actors (including opaque composite actors
        // and flattening transparent composite actors)
        while (embeddedActorsIterator.hasNext()) {
            Actor embeddedActor = (Actor) embeddedActorsIterator.next();

            // Find the successor of the output ports of current actor.
            Iterator successors = embeddedActor.outputPortList().iterator();

            while (successors.hasNext()) {
                IOPort outPort = (IOPort) successors.next();

                // Find the inside ports connected to outPort.
                // NOTE: sinkPortList() is an expensive operation,
                // and it may return ports that are not physically
                // connected (as in wireless ports).  Hence, we
                // use getRemoteReceivers() here. EAL
                Receiver[][] receivers = outPort.getRemoteReceivers();

                for (int i = 0; i < receivers.length; i++) {
                    // FIXME: For ParameterPort, it is possible that
                    // the downstream receivers are null. It is a
                    // unresolved issue about the semantics of Parameter
                    // Port considering the lazy evaluation of variables.
                    if (receivers[i] != null) {
                        for (int j = 0; j < receivers[i].length; j++) {
                            IOPort ioPort = receivers[i][j].getContainer();

                            if (embeddedActors.contains(ioPort.getContainer())
                                    || outputPorts.contains(ioPort)) {
                                _detailedDependencyGraph.addEdge(outPort,
                                        ioPort);
                            }
                        }
                    }
                }
            }
        }

        // Last, connect the container inputs to the inside
        // ports receiving tokens from these inputs.
        Iterator inputs = actor.inputPortList().listIterator();

        while (inputs.hasNext()) {
            IOPort inputPort = (IOPort) inputs.next();

            // Find the inside ports connected to this input port.
            // NOTE: insideSinkPortList() is an expensive operation,
            // and it may return ports that are not physically
            // connected (as in wireless ports).  Hence, we
            // use deepGetReceivers() here. EAL
            Receiver[][] receivers = inputPort.deepGetReceivers();

            for (int i = 0; i < receivers.length; i++) {
                for (int j = 0; j < receivers[i].length; j++) {
                    IOPort ioPort = receivers[i][j].getContainer();
                    Actor ioPortContainer = (Actor) ioPort.getContainer();

                    // The receivers may belong to either the inputs of
                    // contained actors, or the outputs of the container.
                    if (embeddedActors.contains(ioPortContainer)
                            || actor.equals(ioPortContainer)) {
View Full Code Here

     */
    private void _categorizeActors(List actorList) {
        Iterator actors = actorList.listIterator();

        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();

            if (actor instanceof AtomicActor) {
                // Atomic actors have type.
                if (actor instanceof Source) {
                    _sourceActors.add(actor);
                } else if (actor instanceof Sink) {
                    _sinkActors.add(actor);
                } else {
                    _transformers.add(actor);
                }
            } else {
                // Composite actors are categorized based
                // on their ports
                int numberOfInputs = actor.inputPortList().size();
                int numberOfOutputs = actor.outputPortList().size();

                if (numberOfInputs == 0) {
                    _sourceActors.add(actor);
                } else if (numberOfOutputs == 0) {
                    _sinkActors.add(actor);
View Full Code Here

     */
    private void _mergeActorsGraph(List actorList) {
        Iterator actors = actorList.iterator();

        while (actors.hasNext()) {
            Actor embeddedActor = (Actor) actors.next();
            FunctionDependency functionDependency = embeddedActor
                    .getFunctionDependency();

            if (functionDependency != null) {
                _detailedDependencyGraph.addGraph(functionDependency
                        .getDependencyGraph());
View Full Code Here

        Schedule schedule = scheduler.getSchedule();
        Iterator firings = schedule.firingIterator();

        while (firings.hasNext() && !_stopRequested) {
            Firing firing = (Firing) firings.next();
            Actor actor = firing.getActor();
            int iterationCount = firing.getIterationCount();

            if (_debugging) {
                _debug(new FiringEvent(this, actor, FiringEvent.BEFORE_ITERATE,
                        iterationCount));
            }

            int returnValue = actor.iterate(iterationCount);

            if (returnValue == STOP_ITERATING) {
                _postfireReturns = false;
            } else if (returnValue == NOT_READY) {
                throw new IllegalActionException(this, actor, "Actor "
View Full Code Here

        boolean isIDefined = false;
        Iterator actorsToFire = schedule.firingIterator();
        while (actorsToFire.hasNext()) {
            Firing firing = (Firing) actorsToFire.next();
            Actor actor = firing.getActor();

            // FIXME: Before looking for a helper class, we should check to
            // see whether the actor contains a code generator attribute.
            // If it does, we should use that as the helper.
            CodeGeneratorHelper helper = (CodeGeneratorHelper) _getHelper((NamedObj) actor);

            if (inline) {
                for (int i = 0; i < firing.getIterationCount(); i++) {

                    // generate fire code for the actor
                    code.append(helper.generateFireCode());
                    code.append(helper.generateTypeConvertFireCode());

                    // update buffer offset after firing each actor once
                    Iterator inputPorts = actor.inputPortList().iterator();
                    while (inputPorts.hasNext()) {
                        IOPort port = (IOPort) inputPorts.next();
                        int rate = DFUtilities.getRate(port);
                        _updatePortOffset(port, code, rate);
                    }

                    Iterator outputPorts = actor.outputPortList().iterator();
                    while (outputPorts.hasNext()) {
                        IOPort port = (IOPort) outputPorts.next();
                        int rate = DFUtilities.getRate(port);
                        _updateConnectedPortsOffset(port, code, rate);
                    }
                }
            } else {

                int count = firing.getIterationCount();
                if (count > 1) {
                    if (!isIDefined) {
                        code.append(CodeStream.indent("int i;" + _eol));
                        isIDefined = true;
                    }
                    code.append(CodeStream.indent("for (i = 0; i < " + count
                            + " ; i++) {" + _eol));
                    CodeStream.setIndentLevel(2);
                }

//                code.append(CodeStream.indent(CodeGeneratorHelper
//                        .generateName((NamedObj) actor)
//                        + "();" + _eol));

                // metroii
                String actor_name = CodeGeneratorHelper.generateName((NamedObj) actor);
                if(actor_name.startsWith("_"))
                {
                        actor_name = actor_name.substring(1);
                }
                String actor_fire_func_name = actor_name + "();\n";
               
                // FIXME only support top level director
                actor_fire_func_name = "/*****FIRING_ACTOR:"+actor_name+"*****/\n"+actor_fire_func_name+"/*****done "+actor_name+"*****/\n\n";
                code.append(actor_fire_func_name);
               
               
                // update buffer offset after firing each actor once
                Iterator inputPorts = actor.inputPortList().iterator();
                while (inputPorts.hasNext()) {
                    IOPort port = (IOPort) inputPorts.next();
                    int rate = DFUtilities.getRate(port);
                    _updatePortOffset(port, code, rate);
                }

                Iterator outputPorts = actor.outputPortList().iterator();
                while (outputPorts.hasNext()) {
                    IOPort port = (IOPort) outputPorts.next();
                    int rate = DFUtilities.getRate(port);
                    _updateConnectedPortsOffset(port, code, rate);
                }
View Full Code Here

    public String createOffsetVariablesIfNeeded() throws IllegalActionException {
        StringBuffer code = new StringBuffer();
        Iterator actors = ((CompositeActor) _director.getContainer())
                .deepEntityList().iterator();
        while (actors.hasNext()) {
            Actor actor = (Actor) actors.next();
            CodeGeneratorHelper helperObject = (CodeGeneratorHelper) _getHelper((NamedObj) actor);
            code.append(helperObject.createOffsetVariablesIfNeeded());
        }
        return code.toString();
    }
View Full Code Here

TOP

Related Classes of ptolemy.actor.Actor

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.