Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Workspace


    /**
     */
    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");
View Full Code Here


    public boolean loadMoML(String moml) throws java.rmi.RemoteException {
        if (VERBOSE) {
            System.out.println("Loading: " + moml);
        }

        momlParser = new MoMLParser(new Workspace());
        compositeActor = null;

        String processedMoML = processMoML(moml);

        try {
View Full Code Here

                            + "class definition");
        }

        // Use the workspace of the container, if there is one,
        // or the workspace of this object, if there isn't.
        Workspace workspace = workspace();

        if (container != null) {
            workspace = container.workspace();
        }
View Full Code Here

     @return Return true if the get() method of this receiver will
     *   return a token without throwing a NoTokenException.  Return
     *   false if the current thread is not a DDEThread.
     */
    public boolean hasToken() {
        Workspace workspace = getContainer().workspace();
        Thread thread = Thread.currentThread();

        if (!(thread instanceof DDEThread)) {
            return false;
        }

        TimeKeeper timeKeeper = ((DDEThread) thread).getTimeKeeper();

        boolean sendNullTokens = false;

        synchronized (_director) {
            //////////////////////
            // Update the ReceiverList
            //////////////////////
            timeKeeper.updateReceiverList(this);

            /////////////////////////////////////////
            // Determine if this Receiver is in Front
            /////////////////////////////////////////
            if (this != timeKeeper.getFirstReceiver()) {
                return false;
            }

            //////////////////////////////////////////
            // Determine if the TimeKeeper is inactive
            //////////////////////////////////////////
            if (timeKeeper.getNextTime().getDoubleValue() == INACTIVE) {
                requestFinish();
            }

            ///////////////////
            // Check Receiver Times
            ///////////////////
            if ((getReceiverTime().getDoubleValue() == IGNORE) && !_terminate) {
                timeKeeper.removeAllIgnoreTokens();

                sendNullTokens = true;
            }

            ///////////////////////////
            // Check Token Availability
            ///////////////////////////
            if (super.hasToken() && !_terminate && !sendNullTokens) {
                if (!_hasNullToken()) {
                    _hasTokenCache = true;
                    return true;
                } else {
                    // Treat Null Tokens Normally For Feedback
                    if (!_hideNullTokens) {
                        _hasTokenCache = true;
                        return true;
                    }

                    // Deal With Null Tokens Separately
                    super.get();
                    sendNullTokens = true;
                }
            }

            ////////////////////////
            // Perform Blocking Read
            ////////////////////////
            if (!super.hasToken() && !_terminate && !sendNullTokens) {
                _readPending = thread;
                _director.threadBlocked(thread, this, DDEDirector.READ_BLOCKED);

                while ((_readPending != null) && !_terminate) {
                    try {
                        workspace.wait(_director);
                    } catch (InterruptedException e) {
                        _terminate = true;
                        break;
                    }
                }
View Full Code Here

     @param time The specified time stamp.
     *  @exception TerminateProcessException If activity is scheduled
     *   to cease.
     */
    public void put(Token token, Time time) {
        Workspace workspace = getContainer().workspace();

        synchronized (_director) {
            if ((time.compareTo(_getCompletionTime()) > 0)
                    && (_getCompletionTime().getDoubleValue() != ETERNITY)
                    && !_terminate) {
                try {
                    time = new Time(_director, INACTIVE);
                } catch (IllegalActionException e) {
                    // If the time resolution of the director is invalid,
                    // it should have been caught before this.
                    throw new InternalErrorException(e);
                }
            }

            if (super.hasRoom() && !_terminate) {
                super.put(token, time);

                // If any thread is blocked on a get(), then it will become
                // unblocked. Notify the director now so that there isn't a
                // spurious deadlock detection.
                if (_readPending != null) {
                    _director.threadUnblocked(_readPending, this,
                            DDEDirector.READ_BLOCKED);
                    _readPending = null;
                }

                return;
            }

            if (!super.hasRoom() && !_terminate) {
                _writePending = Thread.currentThread();
                _director.threadBlocked(_writePending, this,
                        DDEDirector.WRITE_BLOCKED);

                while ((_writePending != null) && !_terminate) {
                    try {
                        workspace.wait(_director);
                    } catch (InterruptedException e) {
                        _terminate = true;
                        break;
                    }
                }
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");

View Full Code Here

@Pt.AcceptedRating Red (cxh)
*/
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");

View Full Code Here

     */
    public String checkCopy(String momlToBeChecked, NamedObj container)
            throws IllegalActionException {

        _variableBuffer = new StringWriter();
        Workspace workspace = new Workspace("copyWorkspace");
        MoMLParser parser = new MoMLParser(workspace);
        TypedCompositeActor parsedContainer = null;

        // Attempt to parse the moml.  If we fail, check the exception
        // for a missing variable.  If a missing variable is found
View Full Code Here

        TestWorkspace6 tw = new TestWorkspace6();
        tw.runTest();
    }

    public void initializeTest() {
        Workspace workspace = new Workspace();
        List actions = new LinkedList();
        AccessAction action = new AccessAction(workspace, 0, 'R', 0, null,
                _record, "A0");
        actions.add(action);
        action = new AccessAction(workspace, 0, 'R', 0, null, _record, "A1");
View Full Code Here

@Pt.AcceptedRating Red (cxh)

*/
public class TestWorkspace3 extends TestWorkspaceBase {
    public void initializeTest() {
        Workspace workspace = new Workspace();
        List actions = new LinkedList();
        AccessAction action = new AccessAction(workspace, 0, 'R', 1000, null,
                _record, "A1");
        actions.add(action);
        action = new AccessAction(workspace, 0, 'W', 1000, null, _record, "A2");
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Workspace

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.