Package ptolemy.actor

Examples of ptolemy.actor.CompositeActor


                    + ") {" + _eol);
        }

        // If we are not using a C switch, save the default refinement and
        // output it last
        CompositeActor defaultRefinement = null;

        int refinementCount = 0;

        Iterator refinements = container.deepEntityList().iterator();
        while (refinements.hasNext()) {
            boolean fireRefinement = true;
            refinementCount++;
            CompositeActor refinement = (CompositeActor) refinements.next();
            CodeGeneratorHelper refinementHelper = (CodeGeneratorHelper) _getHelper(refinement);
            String refinementName = refinement.getName();
            if (!refinementName.equals("default")) {
                if (useSwitch) {
                    code.append(_INDENT2 + "case " + refinementName + ":");
                } else {
                    if (refinementCount == 1) {
View Full Code Here


        if (director == null) {
            throw new NotSchedulableException(this, "SRRandomizedScheduler "
                    + "cannot schedule graph with no director.");
        }

        CompositeActor compositeActor = (CompositeActor) (director
                .getContainer());

        if (compositeActor == null) {
            throw new NotSchedulableException(this, "SRRandomizedScheduler "
                    + "cannot schedule graph with no container.");
        }

        List actorList = compositeActor.deepEntityList();

        Collections.shuffle(actorList);

        Schedule schedule = new Schedule();
        Iterator actorIterator = actorList.iterator();
View Full Code Here

        if (director == null) {
            throw new NotSchedulableException(this, "SROptimizedScheduler "
                    + "cannot schedule graph with no director.");
        }

        CompositeActor compositeActor = (CompositeActor) (director
                .getContainer());

        if (compositeActor == null) {
            throw new NotSchedulableException(this, "SROptimizedScheduler "
                    + "cannot schedule graph with no container.");
        }

        FunctionDependencyOfCompositeActor functionDependency = (FunctionDependencyOfCompositeActor) compositeActor
                .getFunctionDependency();

        Object[] cycleNodes = functionDependency.getCycleNodes();

        if (cycleNodes.length != 0) {
View Full Code Here

     @return A string representation of the buffer sizes.
     */
    public String displayBufferSizes() {
        StringBuffer result = new StringBuffer();
        PSDFDirector director = (PSDFDirector) getContainer();
        CompositeActor model = (CompositeActor) director.getContainer();
        Iterator relations = model.relationList().iterator();

        while (relations.hasNext()) {
            Relation relation = (Relation) relations.next();
            Variable variable = (Variable) relation.getAttribute("bufferSize");
            result.append(relation.getName() + ": ");
View Full Code Here

     *  external ports are not correct.
     */
    protected Schedule _getSchedule() throws NotSchedulableException,
            IllegalActionException {
        PSDFDirector director = (PSDFDirector) getContainer();
        CompositeActor model = (CompositeActor) director.getContainer();

        // Get the vectorization factor.
        String vectorizationFactorExpression = "1";

        String vectorizationName = director.vectorizationFactor.getName(model);
        vectorizationFactorExpression = vectorizationName.replaceAll("\\.",
                "::");

        if (vectorizationFactorExpression.indexOf(" ") != -1) {
            throw new InternalErrorException("The vectorizationFactor "
                    + "PSDFDirector parameter must "
                    + "not have spaces in its value.  The original value "
                    + "was \"" + vectorizationName
                    + "\". Try changing the name of " + "director.");
        }

        PSDFGraphReader graphReader = new PSDFGraphReader();
        PSDFGraph graph = (PSDFGraph) graphReader.convert(model);
        _debug("PSDF graph = \n" + graph.toString());

        if (_debugFlag) {
            graph.printEdgeRateExpressions();
        }

        PSDFAPGANStrategy strategy = new PSDFAPGANStrategy(graph);
        ptolemy.graph.sched.Schedule graphSchedule = strategy.schedule();
        _debug("P-APGAN schedule = \n" + graphSchedule.toString());

        SymbolicScheduleElement resultSchedule = _expandAPGAN(graph, strategy
                .getClusterManager().getRootNode(), strategy);
        resultSchedule.setIterationCount(vectorizationFactorExpression);

        _debug("Final schedule = \n" + resultSchedule.toString());

        if (_debugging) {
            _debug("The buffer size map:\n");

            Iterator relations = _bufferSizeMap.keySet().iterator();

            while (relations.hasNext()) {
                Relation relation = (Relation) relations.next();
                _debug(relation.getName() + ": " + _bufferSizeMap.get(relation)
                        + "\n");
            }
        }

        _saveBufferSizes(_bufferSizeMap);

        // Crazy hack to infer firing counts for each actor.
        try {
            _inferFiringCounts(resultSchedule, null);
        } catch (NameDuplicationException ex) {
            throw new NotSchedulableException(null, ex,
                    "Error recording firing counts");
        }

        // Crazy hack to Infer port production: FIXME: This should be
        // done as part of the APGAN expansion where the rates of
        // external ports are unknown The reason is that it will make
        // rate information propagate from an actor input port to
        // another actors input port that are connected on the inside
        // to the same external input port.  See
        // BaseSDFScheduler.setContainerRates.
        Iterator ports = model.portList().iterator();

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

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

        // and have the same value.  (Note that the controller
        // itself makes transitions less often if its executive director
        // is an HDFFSMDirector, which is a subclass of MultirateFSMDirector.
        ConstVariableModelAnalysis analysis = ConstVariableModelAnalysis
                .getAnalysis(this);
        CompositeActor model = (CompositeActor) getContainer();

        for (Iterator ports = model.portList().iterator(); ports.hasNext();) {
            IOPort port = (IOPort) ports.next();

            if (!(port instanceof ParameterPort)) {
                if (port.isInput()) {
                    _declareReconfigurationDependencyForRefinementRateVariables(
View Full Code Here

    protected CompositeActor _getEnclosingDomainActor()
            throws IllegalActionException {
        // Keep moving up towards the toplevel of the hierarchy until
        // we find an executive director that is not an instance of
        // MultirateFSMDirector or until we reach the toplevel composite actor.
        CompositeActor container = (CompositeActor) getContainer();
        Director director = container.getExecutiveDirector();

        while (director != null) {
            if (director instanceof MultirateFSMDirector) {
                // Move up another level in the hierarchy.
                container = (CompositeActor) (container.getContainer());
                director = container.getExecutiveDirector();
            } else {
                return container;
            }
        }
View Full Code Here

    protected boolean _updateInputTokenConsumptionRates(
            TypedCompositeActor actor) throws IllegalActionException {
        boolean inputRateChanged = false;

        // Get the current refinement's container.
        CompositeActor refineInPortContainer = (CompositeActor) actor
                .getContainer();

        // Get all of its input ports of the current refinement actor.
        Iterator refineInPorts = actor.inputPortList().iterator();

        while (refineInPorts.hasNext()) {
            IOPort refineInPort = (IOPort) refineInPorts.next();

            // Get all of the input ports this port is linked to on
            // the outside (should only consist of 1 port).
            Iterator inPortsOutside = refineInPort.deepConnectedInPortList()
                    .iterator();

            if (!inPortsOutside.hasNext()) {
                throw new IllegalActionException("Current "
                        + "state's refining actor has an input port not"
                        + "connected to an input port of its container.");
            }

            while (inPortsOutside.hasNext()) {
                IOPort inputPortOutside = (IOPort) inPortsOutside.next();

                // Check if the current port is contained by the
                // container of the current refinement.
                ComponentEntity thisPortContainer = (ComponentEntity) inputPortOutside
                        .getContainer();

                if (thisPortContainer.getFullName().equals(
                        refineInPortContainer.getFullName())) {
                    // set the outside port rate equal to the port rate
                    // of the refinement.
                    int previousPortRate = DFUtilities
                            .getTokenConsumptionRate(inputPortOutside);
                    int portRateToSet = DFUtilities
View Full Code Here

    protected boolean _updateOutputTokenProductionRates(
            TypedCompositeActor actor) throws IllegalActionException {
        boolean outputRateChanged = false;

        // Get the current refinement's container.
        CompositeActor refineOutPortContainer = (CompositeActor) actor
                .getContainer();

        // Get all of the current refinement's output ports.
        Iterator refineOutPorts = actor.outputPortList().iterator();

        while (refineOutPorts.hasNext()) {
            IOPort refineOutPort = (IOPort) refineOutPorts.next();

            Iterator outPortsOutside = refineOutPort.deepConnectedOutPortList()
                    .iterator();

            while (outPortsOutside.hasNext()) {
                IOPort outputPortOutside = (IOPort) outPortsOutside.next();

                // Check if the current port is contained by the
                // container of the current refinment.
                ComponentEntity thisPortContainer = (ComponentEntity) outputPortOutside
                        .getContainer();

                if (thisPortContainer.getFullName().equals(
                        refineOutPortContainer.getFullName())) {
                    // set the outside port rate equal to the port rate
                    // of the refinement.
                    int previousPortRate = DFUtilities
                            .getTokenProductionRate(outputPortOutside);
                    int portRateToSet = DFUtilities
View Full Code Here

     */
    public void fire() throws IllegalActionException {
        FSMActor controller = getController();
        controller.readInputs();

        CompositeActor container = (CompositeActor) getContainer();
        List inputPortList = container.inputPortList();
        State currentState = controller.currentState();

        // Choose a nonpreemptive transition.
        List enabledTransitions = controller.enabledTransitions(currentState
                .preemptiveTransitionList());
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.