Package ptolemy.data

Examples of ptolemy.data.Token


     * the next input.
     */
    public Token getNextToken() throws IllegalActionException {
        // FIXME: This method is used by HelloWorld.PrintString()
        // Is this method necessary
        Token token = _getNextInput();

        if (token instanceof NullToken) {
            return getNextToken();
        }

View Full Code Here


     @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        if (_firstFire) {
            request.broadcast(new Token());
            _firstFire = false;
            return;
        }

        DEDirector dir = (DEDirector) getDirector();
View Full Code Here

        // NOTE: Is there a better way to determine whether the input
        // is complex?
        boolean complex = inputValues[0] instanceof ComplexToken;

        for (int i = _numberOfLags; i >= 0; i--) {
            Token sum = inputValues[0].zero();

            for (int j = 0; j < (_numberOfInputs - i); j++) {
                if (complex) {
                    ComplexToken conjugate = new ComplexToken(
                            ((ComplexToken) inputValues[j]).complexValue()
                                    .conjugate());
                    sum = sum.add(conjugate.multiply(inputValues[j + i]));
                } else {
                    sum = sum.add(inputValues[j].multiply(inputValues[j + i]));
                }
            }

            if (biasedValue) {
                _outputs[(i + _numberOfLags) - notSymmetric] = sum
                        .divide(numberOfInputs.getToken());
            } else {
                _outputs[(i + _numberOfLags) - notSymmetric] = sum
                        .divide(new IntToken(_numberOfInputs - i));
            }
        }

        // Now fill in the first half, which by symmetry is just
View Full Code Here

        for (int i = 0; i < width; i++) {
            String value;

            if (input.isKnown(i)) {
                if (input.hasToken(i)) {
                    Token token = input.get(i);

                    // If the window has been deleted, read the
                    // rest of the inputs.
                    if (textArea == null) {
                        continue;
                    }

                    value = token.toString();

                    // If it is a pure string, strip the quotation marks.
                    if ((value.length() > 1) && value.startsWith("\"")
                            && value.endsWith("\"")) {
                        value = value.substring(1, value.length() - 1);
View Full Code Here

                                    break;
                                }
                                if (_debugging) {
                                    _debug("** Waiting for input.");
                                }
                                Token token = input.get(0);
                                _buffer.add(token);
                                if (_debugging) {
                                    _debug("** Received input. Buffer contents: "
                                            + _buffer);
                                }
                                director.threadUnblocked(writeThread, null);
                                director.notifyAll();
                            }
                        }
                    } catch (TerminateProcessException ex) {
                        // OK, just exit.
                        _postfireReturns = false;
                    } catch (IllegalActionException ex) {
                        _exception = ex;
                    } finally {
                        director.removeThread(_readThread);
                        if (_debugging) {
                            _debug("** Ending read thread.");
                        }
                    }
                }
            };
            director.addThread(_readThread);
            _readThread.start();
        }
        // Synchronize on the director since all read/write
        // operations do.
        synchronized (director) {
            if (_exception != null) {
                throw _exception;
            }
            while (_buffer.size() == 0) {
                if (_stopRequested || !_postfireReturns) {
                    _postfireReturns = false;
                    return;
                }
                if (_debugging) {
                    _debug("Buffer is empty. Waiting for it to fill.");
                }
                try {
                    director.threadBlocked(writeThread, null);
                    RendezvousReceiver.waitForChange(director);
                } catch (TerminateProcessException ex) {
                    _postfireReturns = false;
                    return;
                } finally {
                    director.threadUnblocked(writeThread, null);
                }
                if (_exception != null) {
                    throw _exception;
                }
            }
            // There is a token.
            Token token = (Token) _buffer.get(0);
            if (_debugging) {
                _debug("Sending token to output: " + token);
            }
            if (_exception != null) {
                throw _exception;
View Full Code Here

    }

    /** Writes successive integers to the output
     */
    public void fire() throws IllegalActionException {
        Token data;

        while (true) {
            data = _input.get(0);
            _list.append(((IntToken) data).intValue());

View Full Code Here

                    if (director instanceof PtinyOSDirector) {
                        Attribute nodeID = director.getAttribute("nodeID");
                        if (nodeID instanceof PtinyOSNodeParameter) {
                            // Get the token that stores the node ID.
                            try {
                                Token nodeIDToken = ((PtinyOSNodeParameter) nodeID)
                                        .getToken();

                                if (nodeIDToken instanceof IntToken) {
                                    // Get the integer value of nodeID
                                    int nodeIDValue = ((IntToken) nodeIDToken)
View Full Code Here

                            // operations do.
                            synchronized (director) {
                                if (_debugging) {
                                    _debug("Resources available: " + _pool);
                                }
                                Token resource = RendezvousReceiver.getFromAny(
                                        release.getReceivers(), director);
                                _pool.add(resource);
                                director.threadUnblocked(writeThread, null);
                                director.notifyAll();
                            }
                        }
                    } catch (TerminateProcessException ex) {
                        // OK, just exit
                        _postfireReturns = false;
                    } finally {
                        director.removeThread(_readThread);
                    }
                }
            };
            director.addThread(_readThread);
            _readThread.start();
        } else if (release.getWidth() == 0 && _readThread != null) {
            // A mutation has eliminated the sources.
            _readThread.interrupt();
        }
        // Synchronize on the director since all read/write
        // operations do.
        synchronized (director) {
            while (_pool.size() == 0) {
                if (_stopRequested || !_postfireReturns) {
                    _postfireReturns = false;
                    return;
                }
                try {
                    director.threadBlocked(writeThread, null);
                    RendezvousReceiver.waitForChange(director);
                } catch (TerminateProcessException ex) {
                    _postfireReturns = false;
                    return;
                } finally {
                    director.threadUnblocked(writeThread, null);
                }
            }
            // There is a token.
            Token token = (Token) _pool.get(0);
            // If this put blocks for any reason, it will block on
            // a director.wait(), so the lock will not be held.
            try {
                RendezvousReceiver.putToAny(token, grant.getRemoteReceivers(),
                        director);
View Full Code Here

     * @exception NoTokenException If the queue is empty.
     */
    public Token get() {
        // Get a token and set all relevant
        // local time parameters
        Token token = null;
        Event event = (Event) _queue.take();

        if (event == null) {
            throw new NoTokenException(getContainer(),
                    "Attempt to get token from an empty "
View Full Code Here

            CompositeActor model = (CompositeActor) getContainer();
            IOPort port = (IOPort) model.getPort(parameter);
            if (port != null) {
                if (port instanceof ParameterPort) {
                    Token token = ((ParameterPort) port).getParameter()
                        .getToken();
                    if (token != null) {
                        DoubleToken doubleToken = DoubleToken.convert(token);
                        parameterValue = (char) doubleToken.doubleValue();
                    } else {
View Full Code Here

TOP

Related Classes of ptolemy.data.Token

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.