Package ptolemy.actor

Examples of ptolemy.actor.Manager


                            "Failed to read model.");
                }

                // Create a manager, if appropriate.
                if (_model instanceof CompositeActor) {
                    _manager = new Manager(_model.workspace(), "Manager");
                    ((CompositeActor) _model).setManager(_manager);

                    if (_debugging) {
                        _debug("** Created new manager.");
                    }
View Full Code Here


                            "Failed to read model from: " + url);
                }

                // Create a manager, if appropriate.
                if (_model instanceof CompositeActor) {
                    _manager = new Manager(_model.workspace(), "Manager");
                    ((CompositeActor) _model).setManager(_manager);

                    if (_debugging) {
                        _debug("** Created new manager.");
                    }
View Full Code Here

            try {
                boolean runValue = ((BooleanToken) runOnModification.getToken())
                        .booleanValue();

                if (runValue) {
                    Manager manager = getManager();

                    if ((manager != null)
                            && (manager.getState() == Manager.IDLE)) {
                        // Instead of calling manager.startRun(),
                        // call manager.execute().
                        // Otherwise applets have problems.
                        manager.execute();
                    }
                }
            } catch (ptolemy.kernel.util.KernelException ex) {
                // Should be thrown only if the manager is not idle, or
                // if the parameter is not boolean valued.
View Full Code Here

     * @exception IllegalActionException If failed to execute the model.
     */
    public static synchronized RecordToken executeModel(CompositeActor model,
            RecordToken args, String[] resultLabels)
            throws IllegalActionException {
        Manager manager = model.getManager();

        if (manager == null) {
            //System.out.println("create manager for the model");
            manager = new Manager(model.workspace(), "Manager");
            model.setManager(manager);
        }

        _setAttribute(model, args);

        try {
            manager.execute();
        } catch (KernelException ex) {
            throw new IllegalActionException(ex + "Execution failed.");
        }

        return _getResult(model, resultLabels);
View Full Code Here

        // If the model is not idle or paused, then pause it while saving
        // This solves bug where if we have Const -> MonitorValue with
        // SDFDirector with default parameters and run it and then do
        // SaveAs, we got strange behaviour.
        if (_model instanceof CompositeActor) {
            Manager manager = ((CompositeActor) _model).getManager();

            if (manager != null) {
                Manager.State state = manager.getState();

                if ((state == Manager.IDLE) && (state == Manager.PAUSED)) {
                    return super._saveAs();
                } else {
                    manager.pause();

                    boolean returnValue = super._saveAs();
                    manager.resume();
                    return returnValue;
                }
            }
        }
View Full Code Here

        // Set up Manager, Director and top level CompositeActor
        Workspace workSpc = new Workspace();
        TypedCompositeActor topLevelActor = new TypedCompositeActor(workSpc);
        topLevelActor.setName("universe");

        Manager manager = new Manager(workSpc, "manager");
        DDEDirector director = new DDEDirector(topLevelActor, "director");
        Parameter stopTime = (Parameter) director.getAttribute("stopTime");
        stopTime.setToken(new DoubleToken(57.0));
        topLevelActor.setManager(manager);

        // Set up next level actors
        Clock vowelSrc = new Clock(topLevelActor, "vowelSrc");
        vowelSrc.values.setExpression("{1,1,1,1,1,1,1,1,1,1,1,1,1}");
        vowelSrc.period.setToken(new DoubleToken(100.0));
        vowelSrc.offsets
                .setExpression("{0.5,2.0,5.0,7.0,8.0,11.0,12.5,13.5,14.0,15.5,17.5,19.5,20.5}");
        vowelSrc.stopTime.setToken(new DoubleToken(30.0));

        Clock consonantsSrc = new Clock(topLevelActor, "consonantsSrc");
        consonantsSrc.values
                .setExpression("{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}");
        consonantsSrc.period.setToken(new DoubleToken(100.0));
        consonantsSrc.offsets
                .setExpression("{0.0, 1.0, 1.5, 4.0, 4.5, 6.0, 6.5, 7.5, 8.5, 9.0, 10.0, 10.5, 12.0, 13.0, 14.5, 16.0, 17.0, 18.0, 18.5, 19.0, 20.0}");
        consonantsSrc.stopTime.setToken(new DoubleToken(30.0));

        Clock punctuationSrc = new Clock(topLevelActor, "punctuationSrc");
        punctuationSrc.values.setExpression("{1, 1, 1, 1, 1, 1, 1, 1, 1}");
        punctuationSrc.period.setToken(new DoubleToken(100.0));
        punctuationSrc.offsets
                .setExpression("{2.5, 3.0, 3.5, 5.5, 9.5, 11.5, 15.0, 16.5, 21.0}");
        punctuationSrc.stopTime.setToken(new DoubleToken(30.0));

        PrintString printer = new PrintString(topLevelActor, "printer");
        Consonants consonants = new Consonants(topLevelActor, "consonants");
        Vowels vowels = new Vowels(topLevelActor, "vowels");
        Punctuation punctuation = new Punctuation(topLevelActor, "punctuation");

        // System.out.println("Actors have been instantiated.");
        // Set up ports, relation
        TypedIOPort vSrcOut = (TypedIOPort) vowelSrc.getPort("output");
        TypedIOPort cSrcOut = (TypedIOPort) consonantsSrc.getPort("output");
        TypedIOPort pSrcOut = (TypedIOPort) punctuationSrc.getPort("output");

        TypedIOPort cOutput = (TypedIOPort) consonants.getPort("output");
        TypedIOPort vOutput = (TypedIOPort) vowels.getPort("output");
        TypedIOPort pOutput = (TypedIOPort) punctuation.getPort("output");

        TypedIOPort input = (TypedIOPort) printer.getPort("input");

        TypedIOPort cInput = (TypedIOPort) consonants.getPort("input");
        TypedIOPort vInput = (TypedIOPort) vowels.getPort("input");
        TypedIOPort pInput = (TypedIOPort) punctuation.getPort("input");

        // System.out.println("Ports and relations are finished.");
        // Set up connections
        topLevelActor.connect(vSrcOut, vInput);
        topLevelActor.connect(vOutput, input);

        topLevelActor.connect(cSrcOut, cInput);
        topLevelActor.connect(cOutput, input);

        topLevelActor.connect(pSrcOut, pInput);
        topLevelActor.connect(pOutput, input);

        // System.out.println("Connections are complete.");
        // Uncomment the next line to print out the MoML version of the model.
        // System.out.println(topLevelActor.exportMoML());
        System.out.println();
        System.out.println();
        System.out.println();

        manager.run();

        System.out.println();
        System.out.println();
        System.out.println();
        System.out.println();
View Full Code Here

        }

        // Initialize the model to ensure type resolution and scheduling
        // are done.
        try {
            Manager manager = new Manager(_toplevel.workspace(), "manager");
            _toplevel.setManager(manager);
            manager.preinitializeAndResolveTypes();
        } catch (Exception exception) {
            throw new KernelRuntimeException(exception,
                    "Could not initialize composite actor");
        }
    }
View Full Code Here

        toplevel.setName("toplevel");

        DEDirector director = new DEDirector(toplevel, "director");

        //director.addDebugListener(new StreamListener());
        Manager manager = new Manager(w, "manager");
        toplevel.setManager(manager);

        TestSource source1 = new TestSource(toplevel, "source1");
        TestSource source2 = new TestSource(toplevel, "source2");
        _recorder = new Recorder(toplevel, "recorder");

        toplevel.connect(source1.output, source2.input);
        toplevel.connect(source2.output, _recorder.input);

        director.startTime.setToken(new DoubleToken(0.0));
        director.stopTime.setToken(new DoubleToken(1000.0));
        manager.initialize();
        manager.iterate();
        manager.iterate();
        manager.wrapup();
    }
View Full Code Here

                        // Tell the manager to initialize the actor.
                        // NOTE: If the manager is null, then we can't
                        // possibly be executing, so we don't need to do
                        // this.
                        Manager manager = getManager();

                        if ((manager != null)
                                && (manager.getState() != Manager.IDLE)) {
                            manager.requestInitialization(localActor);
                        }

                        // NOTE: Probably don't want this overhead.
                        // ((NamedObj)localActor).addDebugListener(this);
                    } catch (KernelException e) {
View Full Code Here

        toplevel.setName("toplevel");

        DEDirector director = new DEDirector(toplevel, "director");

        // director.addDebugListener(new StreamListener());
        Manager manager = new Manager(w, "manager");
        toplevel.setManager(manager);

        Merge merge = new Merge(toplevel, "merge");

        // Create 20 clocks.
        for (int i = 1; i < 20; i++) {
            Clock clock = new Clock(toplevel, "clock" + i);
            clock.period.setExpression("" + (i * 2));
            clock.values.setExpression("{" + i + ", " + i + "}");
            toplevel.connect(clock.output, merge.input);
        }

        Recorder recorder = new Recorder(toplevel, "recorder");
        recorder.capacity.setExpression("0");

        // TimedPlotter recorder = new TimedPlotter(toplevel, "recorder");
        // recorder.setPanel(null);
        // recorder.plot.setMarksStyle("dots");
        // recorder.plot.setConnected(false);
        toplevel.connect(merge.output, recorder.input);

        director.stopTime.setToken(new DoubleToken(1000.0));
        manager.run();
        manager.run();
        System.out.println("Total number of events seen by Recorder: "
                + recorder.getCount());
    }
View Full Code Here

TOP

Related Classes of ptolemy.actor.Manager

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.