Package ptolemy.actor

Examples of ptolemy.actor.TypedCompositeActor


     @exception IllegalActionException If there is more than one
     *   view screen.
     */
    private ViewScreenInterface _getViewScreen() throws IllegalActionException {
        ViewScreenInterface viewScreen = null;
        TypedCompositeActor container = (TypedCompositeActor) getContainer();
        Iterator actors = container.deepEntityList().iterator();

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

            if (actor instanceof ViewScreenInterface) {
View Full Code Here


            }

            _refinement = new TypedActor[size];

            Nameable container = getContainer();
            TypedCompositeActor containerContainer = (TypedCompositeActor) container
                    .getContainer();
            int index = 0;

            while (tokenizer.hasMoreTokens()) {
                String name = tokenizer.nextToken().trim();

                if (name.equals("")) {
                    throw new IllegalActionException(this,
                            "Malformed list of refinements: " + names);
                }

                if (containerContainer == null) {
                    // If we are doing saveAs of ModalBSC and select
                    // submodel only, then some of the refinements might
                    // not yet have a container (containercontainer == null).
                    // ptolemy.vergil.fsm.StateIcon._getFill() will call
                    // this and properly handles an IllegalActionException
                    throw new IllegalActionException(this, "Container of \""
                            + getFullName()
                            + "\" is null?  This is not always a problem.");
                }

                TypedActor element = (TypedActor) containerContainer
                        .getEntity(name);

                if (element == null) {
                    throw new IllegalActionException(this, "Cannot find "
                            + "refinement with name \"" + name + "\" in "
                            + containerContainer.getFullName());
                }

                _refinement[index++] = element;
            }
View Full Code Here

public class Iterations {
    private Recorder _recorder;

    public Iterations() throws KernelException {
        Workspace w = new Workspace("w");
        TypedCompositeActor toplevel = new TypedCompositeActor(w);
        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();
View Full Code Here

                        "Multiple refinements are not supported."
                                + " Found multiple refinements in: "
                                + currentState.getName());
            }

            TypedCompositeActor currentRefinement = (TypedCompositeActor) (currentRefinements[0]);
            Director refinementDir = currentRefinement.getDirector();

            if (refinementDir instanceof MultirateFSMDirector) {
                refinementDir.initialize();
            }
View Full Code Here

        // that the current state is not null in initialize() method or
        // in the fire() method.
        FSMActor controller = getController();
        State currentState = controller.currentState();
        Transition lastChosenTransition = _getLastChosenTransition();
        TypedCompositeActor actor;
        Director refinementDir;
        boolean superPostfire;

        // Commit the transition.
        superPostfire = super.postfire();
        currentState = controller.currentState();

        TypedActor[] actors = currentState.getRefinement();

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

        actor = (TypedCompositeActor) (actors[0]);

        if (lastChosenTransition != null) {
            refinementDir = actor.getDirector();

            if (refinementDir instanceof MultirateFSMDirector) {
                refinementDir.postfire();
            } else if (refinementDir instanceof StaticSchedulingDirector) {
                // Get the refinement schedule so we can update the
View Full Code Here

            throw new IllegalActionException(this,
                    "Current state is required to have exactly one refinement: "
                            + controller.currentState().getName());
        }

        TypedCompositeActor currentRefinement = (TypedCompositeActor) (currentRefinements[0]);
        _updateInputTokenConsumptionRates(currentRefinement);
        _updateOutputTokenProductionRates(currentRefinement);

        // Declare reconfiguration constraints on the ports of the
        // actor.  The constraints indicate that the ports are
View Full Code Here

*/
public class Time {
    public static void main(String[] arg) throws IllegalActionException,
            NameDuplicationException {
        Workspace w = new Workspace("w");
        TypedCompositeActor toplevel = new TypedCompositeActor(w);
        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: "
View Full Code Here

            }

            _refinement = new TypedActor[size];

            Nameable container = getContainer();
            TypedCompositeActor containerContainer = (TypedCompositeActor) container
                    .getContainer();
            int index = 0;

            while (tokenizer.hasMoreTokens()) {
                String name = tokenizer.nextToken().trim();

                if (name.equals("")) {
                    throw new IllegalActionException(this,
                            "Malformed list of refinements: " + names);
                }

                TypedActor element = (TypedActor) containerContainer
                        .getEntity(name);

                if (element == null) {
                    throw new IllegalActionException(this, "Cannot find "
                            + "refinement with name \"" + name + "\" in "
                            + containerContainer.getFullName());
                }

                _refinement[index++] = element;
            }
View Full Code Here

    private TypedCompositeActor _top;

    private DEDirector _director;

    public Mutate() throws IllegalActionException, NameDuplicationException {
        _top = new TypedCompositeActor();
        _top.setName("top");
        manager = new Manager();
        _director = new DEDirector();
        _top.setDirector(_director);
        _top.setManager(manager);
View Full Code Here

    /** The application code.
     */
    public static void main(String[] args) {
        try {
            TypedCompositeActor univ = new TypedCompositeActor();
            univ.setName("DiningPhilosophers demo");

            Manager manager = new Manager("Manager");
            new CSPDirector(univ, "Local Director");
            univ.setManager(manager);

            Parameter thinkingRate = new Parameter(univ, "thinkingRate");
            thinkingRate.setExpression("1.0");
            thinkingRate.getToken();

            Parameter eatingRate = new Parameter(univ, "eatingRate");
            eatingRate.setExpression("1.0");
            eatingRate.getToken();

            // Set up the actors and connections
            Philosopher p1 = new Philosopher(univ, "Aristotle");
            Philosopher p2 = new Philosopher(univ, "Plato");
            Philosopher p4 = new Philosopher(univ, "Descartes");
            Philosopher p3 = new Philosopher(univ, "Sartre");

            Philosopher p5 = new Philosopher(univ, "Socrates");

            Chopstick f1 = new Chopstick(univ, "Chopstick1");
            Chopstick f2 = new Chopstick(univ, "Chopstick2");
            Chopstick f3 = new Chopstick(univ, "Chopstick3");
            Chopstick f4 = new Chopstick(univ, "Chopstick4");
            Chopstick f5 = new Chopstick(univ, "Chopstick5");

            // Now connect up the Actors
            univ.connect((TypedIOPort) p1.getPort("leftIn"), (TypedIOPort) f5
                    .getPort("rightOut"));
            univ.connect((TypedIOPort) p1.getPort("leftOut"), (TypedIOPort) f5
                    .getPort("rightIn"));
            univ.connect((TypedIOPort) p1.getPort("rightIn"), (TypedIOPort) f1
                    .getPort("leftOut"));
            univ.connect((TypedIOPort) p1.getPort("rightOut"), (TypedIOPort) f1
                    .getPort("leftIn"));
            univ.connect((TypedIOPort) p2.getPort("leftIn"), (TypedIOPort) f1
                    .getPort("rightOut"));
            univ.connect((TypedIOPort) p2.getPort("leftOut"), (TypedIOPort) f1
                    .getPort("rightIn"));
            univ.connect((TypedIOPort) p2.getPort("rightIn"), (TypedIOPort) f2
                    .getPort("leftOut"));
            univ.connect((TypedIOPort) p2.getPort("rightOut"), (TypedIOPort) f2
                    .getPort("leftIn"));
            univ.connect((TypedIOPort) p3.getPort("leftIn"), (TypedIOPort) f2
                    .getPort("rightOut"));
            univ.connect((TypedIOPort) p3.getPort("leftOut"), (TypedIOPort) f2
                    .getPort("rightIn"));
            univ.connect((TypedIOPort) p3.getPort("rightIn"), (TypedIOPort) f3
                    .getPort("leftOut"));
            univ.connect((TypedIOPort) p3.getPort("rightOut"), (TypedIOPort) f3
                    .getPort("leftIn"));
            univ.connect((TypedIOPort) p4.getPort("leftIn"), (TypedIOPort) f3
                    .getPort("rightOut"));
            univ.connect((TypedIOPort) p4.getPort("leftOut"), (TypedIOPort) f3
                    .getPort("rightIn"));
            univ.connect((TypedIOPort) p4.getPort("rightIn"), (TypedIOPort) f4
                    .getPort("leftOut"));
            univ.connect((TypedIOPort) p4.getPort("rightOut"), (TypedIOPort) f4
                    .getPort("leftIn"));
            univ.connect((TypedIOPort) p5.getPort("leftIn"), (TypedIOPort) f4
                    .getPort("rightOut"));
            univ.connect((TypedIOPort) p5.getPort("leftOut"), (TypedIOPort) f4
                    .getPort("rightIn"));
            univ.connect((TypedIOPort) p5.getPort("rightIn"), (TypedIOPort) f5
                    .getPort("leftOut"));
            univ.connect((TypedIOPort) p5.getPort("rightOut"), (TypedIOPort) f5
                    .getPort("leftIn"));

            //System.out.println(univ.description(1023));
            System.out.println(univ.getFullName() + " starting!");
            univ.getManager().startRun();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of ptolemy.actor.TypedCompositeActor

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.