Package ptolemy.kernel

Examples of ptolemy.kernel.Entity


        if (transition == null) {
            throw new IllegalActionException(this,
                    "Action has no container transition.");
        }

        Entity fsm = (Entity) transition.getContainer();

        if (fsm == null) {
            throw new IllegalActionException(this, transition,
                    "Transition has no container.");
        }

        IOPort port = (IOPort) fsm.getPort(name);

        if (port == null) {
            // No port found.  Try for a variable.
            Attribute variable = fsm.getAttribute(name);

            if (variable == null) {
                // Try for a refinement variable.
                int period = name.indexOf(".");

                if (period > 0) {
                    String refinementName = name.substring(0, period);
                    String entryName = name.substring(period + 1);

                    // FIXME: Look in the container of the fsm???
                    // Below we look for an attribute only in the fsm
                    // itself.
                    Nameable fsmContainer = fsm.getContainer();

                    if (fsmContainer instanceof CompositeEntity) {
                        Entity refinement = ((CompositeEntity) fsmContainer)
                                .getEntity(refinementName);

                        if (refinement != null) {
                            Attribute entry = refinement
                                    .getAttribute(entryName);

                            if (entry instanceof Variable) {
                                return entry;
                            }
View Full Code Here


            } else if (getName().equals(routeTo) || (hops == 0)) {
                // Change the color of the icon to green.
                _circle2.fillColor.setToken("{0.0, 1.0, 0.0, 1.0}");

                CompositeEntity container = (CompositeEntity) getContainer();
                Entity destNode = container.getEntity(destination);
                Locatable destLocation = (Locatable) destNode.getAttribute(
                        "_location", Locatable.class);
                Locatable myLocation = (Locatable) this.getAttribute(
                        "_location", Locatable.class);

                if ((destLocation == null) || (myLocation == null)) {
                    throw new IllegalActionException(
                            "Cannot determine location for node "
                                    + destNode.getName() + ".");
                }

                Iterator nodes = _connectedNodes.iterator();
                double minDistance = _distanceBetween(destLocation, myLocation);
                String to = " ";
                boolean multi = ((BooleanToken) doublePath.getToken())
                        .booleanValue();
                double nextMinDistance = _distanceBetween(destLocation,
                        myLocation);
                String to2 = " ";

                while (nodes.hasNext()) {
                    Entity node = (Entity) nodes.next();
                    Locatable location = (Locatable) node.getAttribute(
                            "_location", Locatable.class);

                    if (location == null) {
                        throw new IllegalActionException(
                                "Cannot determine location for node "
                                        + node.getName() + ".");
                    }

                    double d = _distanceBetween(destLocation, location);

                    if (multi) {
                        if (d < minDistance) {
                            nextMinDistance = minDistance;
                            to2 = to;
                            minDistance = d;
                            to = node.getName();
                        } else if (d < nextMinDistance) {
                            nextMinDistance = d;
                            to2 = node.getName();
                        }
                    } else {
                        if (d < minDistance) {
                            minDistance = d;
                            to = node.getName();
                        }
                    }
                }

                // Request refiring after a certain amount of time specified
View Full Code Here

            List result = new LinkedList();
            CompositeEntity container = (CompositeEntity) getContainer();
            Iterator entities = container.entityList().iterator();

            while (entities.hasNext()) {
                Entity entity = (Entity) entities.next();
                Iterator ports = entity.portList().iterator();

                while (ports.hasNext()) {
                    Port port = (Port) ports.next();

                    if (port instanceof WirelessIOPort) {
View Full Code Here

            List result = new LinkedList();
            CompositeEntity container = (CompositeEntity) getContainer();
            Iterator entities = container.entityList().iterator();

            while (entities.hasNext()) {
                Entity entity = (Entity) entities.next();
                Iterator ports = entity.portList().iterator();

                while (ports.hasNext()) {
                    Port port = (Port) ports.next();

                    if (port instanceof WirelessIOPort) {
View Full Code Here

     @return The location of the port.
     *  @exception IllegalActionException If a valid location attribute cannot
     *   be found.
     */
    protected double[] _locationOf(IOPort port) throws IllegalActionException {
        Entity container = (Entity) port.getContainer();
        Locatable location = null;

        if (container == getContainer()) {
            location = (Locatable) port.getAttribute(LOCATION_ATTRIBUTE_NAME,
                    Locatable.class);
        } else {
            location = (Locatable) container.getAttribute(
                    LOCATION_ATTRIBUTE_NAME, Locatable.class);
        }

        if (location == null) {
            throw new IllegalActionException(
View Full Code Here

            String theChannelName) throws IllegalActionException {
        List result = new LinkedList();
        Iterator entities = container.entityList().iterator();

        while (entities.hasNext()) {
            Entity entity = (Entity) entities.next();
            Iterator ports = entity.portList().iterator();

            while (ports.hasNext()) {
                Port port = (Port) ports.next();

                if (port instanceof WirelessIOPort) {
View Full Code Here

     @exception IllegalActionException If a valid location attribute cannot
     *   be found.
     */
    public static double[] locationOf(IOPort port)
            throws IllegalActionException {
        Entity portContainer = (Entity) port.getContainer();
        Locatable location = null;

        //FIXME: What should I do here...
        //if (portContainer == container) {
        //    location = (Locatable)port.getAttribute(LOCATION_ATTRIBUTE_NAME,
        //            Locatable.class);
        //} else {
        location = (Locatable) portContainer.getAttribute(
                LOCATION_ATTRIBUTE_NAME, Locatable.class);

        //}
        if (location == null) {
            throw new IllegalActionException(
View Full Code Here

            String theChannelName) throws IllegalActionException {
        List result = new LinkedList();
        Iterator entities = container.entityList().iterator();

        while (entities.hasNext()) {
            Entity entity = (Entity) entities.next();
            Iterator ports = entity.portList().iterator();

            while (ports.hasNext()) {
                Port port = (Port) ports.next();

                if (port instanceof WirelessIOPort) {
View Full Code Here

            protected void _execute() throws KernelException {
                Iterator entities = entityToFiringsPerIteration.keySet()
                        .iterator();

                while (entities.hasNext()) {
                    Entity entity = (Entity) entities.next();
                    int firingCount = ((Integer) entityToFiringsPerIteration
                            .get(entity)).intValue();
                    DFUtilities.setOrCreate(entity, "firingsPerIteration",
                            firingCount);

                    if (_debugging) {
                        _debug("Adding firingsPerIteration parameter to "
                                + entity.getName() + " with value "
                                + firingCount);
                    }
                }
            }
        };
View Full Code Here

            if (port.isOutput() && port instanceof WirelessIOPort) {
                // Found the port.
                foundOne = true;

                Entity container = (Entity) (port.getContainer());
                String channelName = ((WirelessIOPort) port).outsideChannel
                        .stringValue();
                CompositeEntity container2 = (CompositeEntity) container
                        .getContainer();

                if (container2 == null) {
                    throw new IllegalActionException(this,
                            "The port's container does not have a container.");
                }

                Entity channel = container2.getEntity(channelName);

                if (channel instanceof WirelessChannel) {
                    // Cache it here, so no need to do it again in wrapup().
                    _outputWirelessChannel = (WirelessChannel) channel;
                    _wirelessOutputPort = (WirelessIOPort) port;
                    ((WirelessChannel) channel).registerPropertyTransformer(
                            this, (WirelessIOPort) port);
                } else {
                    throw new IllegalActionException(this,
                            "The connected output port does not refer to a "
                                    + "valid channel.");
                }
            }
        }

        //register this property transformer for the connected wireless
        //input port. It assumes there is only one.
        Iterator connectedInputPorts = input.sourcePortList().iterator();

        while (connectedInputPorts.hasNext()) {
            //register this property transformer for the connected wireless
            //output port. It assumes there is only one.
            IOPort port = (IOPort) connectedInputPorts.next();

            if (port.isInput() && port instanceof WirelessIOPort) {
                // Found the port.
                foundOne = true;

                Entity container = (Entity) (port.getContainer());
                String channelName = ((WirelessIOPort) port).outsideChannel
                        .stringValue();
                CompositeEntity container2 = (CompositeEntity) container
                        .getContainer();

                if (container2 == null) {
                    throw new IllegalActionException(this,
                            "The port's container does not have a container.");
                }

                Entity channel = container2.getEntity(channelName);

                if (channel instanceof WirelessChannel) {
                    // Cache it here, so no need to do it again in wrapup().
                    _inputWirelessChannel = (WirelessChannel) channel;
                    _wirelessInputPort = (WirelessIOPort) port;
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Entity

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.