Package ptolemy.actor

Examples of ptolemy.actor.TypedCompositeActor


    /** Construct the Ptolemy model; instantiate all
     *  actors and make connections.
     */
    protected NamedObj _createModel(Workspace workspace) throws Exception {
        TypedCompositeActor toplevel = new TypedCompositeActor(workspace);
        _toplevel = toplevel;

        DDEDirector director = new DDEDirector(toplevel, "DDE Director");
        director.stopTime.setExpression("90.0");

        // Instantiate the Actors
        _clock = new ListenClock(toplevel, "Clock");
        _clock.values.setExpression("{1, 1, 1}");
        _clock.period.setToken(new DoubleToken(20.0));
        _clock.offsets.setExpression("{5.0, 10.0, 15.0}");

        _join1 = new ListenWire(toplevel, "UpperJoin");
        _fork1 = new ListenFork(toplevel, "UpperFork");
        _fBack1 = new ListenFeedBackDelay(toplevel, "UpperFeedBack");
        _join2 = new ListenWire(toplevel, "LowerJoin");
        _fork2 = new ListenFork(toplevel, "LowerFork");
        _fBack2 = new ZenoDelay(toplevel, "LowerFeedBack");

        _rcvr1 = new ListenSink(toplevel, "UpperRcvr");
        _rcvr2 = new ListenSink(toplevel, "LowerRcvr");

        _upperTime = new Const(toplevel, "upperTime");
        _upperPlotter = new TimedPlotter(toplevel, "upperPlotter");

        _lowerTime = new Const(toplevel, "lowerTime");
        _lowerPlotter = new TimedPlotter(toplevel, "lowerPlotter");

        //_fBack1.delay.setToken(new DoubleToken(4.5));
        //_fBack2.delay.setToken(new DoubleToken(4.5));
        _fBack1.delay.setToken(new DoubleToken(1.0));
        _fBack2.delay.setToken(new DoubleToken(1.0));

        // Set up ports, relations and connections
        Relation clkRelation = toplevel.connect(_clock.output, _join1.input);
        _join2.input.link(clkRelation);

        toplevel.connect(_join1.output, _fork1.input);
        toplevel.connect(_fork1.output1, _rcvr1.input);
        toplevel.connect(_fork1.output2, _fBack1.input);
        toplevel.connect(_fBack1.output, _join1.input);

        toplevel.connect(_join2.output, _fork2.input);
        toplevel.connect(_fork2.output1, _rcvr2.input);
        toplevel.connect(_fork2.output2, _fBack2.input);
        toplevel.connect(_fBack2.output, _join2.input);

        toplevel.connect(_fork1.output1, _upperTime.trigger);
        toplevel.connect(_upperTime.output, _upperPlotter.input);

        toplevel.connect(_fork2.output1, _lowerTime.trigger);
        toplevel.connect(_lowerTime.output, _lowerPlotter.input);

        //System.out.println(toplevel.exportMoML());
        return toplevel;
    }
View Full Code Here


                    }
                }
            }
        }

        TypedCompositeActor container = ((TypedCompositeActor) getContainer());
        Iterator inputPorts = container.inputPortList().iterator();

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

            // NOTE: If the port is a ParameterPort, then we should not
View Full Code Here

     */
    public static void main(String[] args) throws IllegalActionException,
            IllegalStateException, NameDuplicationException {
        // 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();
View Full Code Here

     */
    public void fire() throws IllegalActionException {
        Nameable container = getContainer();

        if (container instanceof TypedCompositeActor) {
            TypedCompositeActor petriContainer = (TypedCompositeActor) container;
            boolean test = _fireHierarchicalPetriNetOnce(petriContainer);

            while (test) {
                test = _fireHierarchicalPetriNetOnce(petriContainer);
            }
View Full Code Here

            Nameable component = (Nameable) components.next();

            if (component instanceof Place) {
                // Don't do anything for Place
            } else if (component instanceof PetriNetActor) {
                TypedCompositeActor componentActor = (TypedCompositeActor) component;
                LinkedList newComponentList = findTransitions(componentActor);
                temporaryList.addAll(newComponentList);
            } else {
                temporaryList.add(component);
            }
View Full Code Here

                if (petriNetActor.prefire()) {
                    readyComponentList.add(petriNetActor);
                }
            } else if (component instanceof TypedCompositeActor) {
                TypedCompositeActor componentTransition = (TypedCompositeActor) component;

                if (isTransitionReady(componentTransition)) {
                    readyComponentList.add(componentTransition);
                }
            }
View Full Code Here

            if (chosenTransition instanceof PetriNetActor) {
                PetriNetActor realPetriNetActor = (PetriNetActor) chosenTransition;
                _fireHierarchicalPetriNetOnce(realPetriNetActor);
            } else if (chosenTransition instanceof TypedCompositeActor) {
                TypedCompositeActor realTransition = (TypedCompositeActor) chosenTransition;
                fireTransition(realTransition);
            }

            return true;
        } else {
View Full Code Here

        while (components.hasNext()) {
            Nameable componentActor = (Nameable) components.next();

            if (componentActor instanceof TypedCompositeActor) {
                TypedCompositeActor transitionComponent = (TypedCompositeActor) componentActor;

                if (director.isTransitionReady(transitionComponent)) {
                    return true;
                }
            }
View Full Code Here

     *
     *  @exception IllegalActionException If there is a problem in
     *   obtaining the number of initial token for delay actors
     */
    private void _debugViewActorTable() throws IllegalActionException {
        TypedCompositeActor container = (TypedCompositeActor) getContainer();
        List entityList = container.entityList();
        _debug("\nACTOR TABLE with " + entityList.size() + " unique actors");
        _debug("---------------------------------------");

        Iterator actors = entityList.iterator();

View Full Code Here

     *
     *  @exception IllegalActionException If an actor executed by this
     *  director returns false in its prefire().
     */
    private void _fire() throws IllegalActionException {
        TypedCompositeActor container = (TypedCompositeActor) getContainer();

        // FIXME: This code works differently than all other
        // synchronizeToRealTime implementations.
        long currentTime = System.currentTimeMillis();
        int frameRate = ((IntToken) iterationTimeLowerBound.getToken())
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.