Package ptolemy.kernel

Examples of ptolemy.kernel.Entity


     @exception IllegalActionException If a valid location attribute cannot
     *   be found.
     */
    private double[] _locationOf(WirelessIOPort port)
            throws IllegalActionException {
        Entity container = (Entity) port.getContainer();
        Locatable location = null;
        location = (Locatable) container.getAttribute(LOCATION_ATTRIBUTE_NAME,
                Locatable.class);

        if (location == null) {
            throw new IllegalActionException(
                    "Cannot determine location for port " + port.getName()
View Full Code Here


        _offset[1] = location.getLocation()[1] + center[1];

        CompositeEntity container = (CompositeEntity) getContainer();
        _channelName = channelName.stringValue();

        Entity channel = container.getEntity(_channelName);

        if (channel instanceof WirelessChannel) {
            _channel = (WirelessChannel) channel;
            ((WirelessChannel) channel).registerPropertyTransformer(this, null);
        } else {
View Full Code Here

     @exception IllegalActionException If a valid location attribute cannot
     *   be found.
     */
    private double[] _locationOf(WirelessIOPort port)
            throws IllegalActionException {
        Entity container = (Entity) port.getContainer();
        Locatable location = null;
        location = (Locatable) container.getAttribute(LOCATION_ATTRIBUTE_NAME,
                Locatable.class);

        if (location == null) {
            throw new IllegalActionException(
                    "Cannot determine location for port " + port.getName()
View Full Code Here

        // Find the channel.
        CompositeEntity container = (CompositeEntity) getContainer();

        if (container != null) {
            Entity channel = container
                    .getEntity(inputChannelName.stringValue());

            if (channel instanceof AtomicWirelessChannel) {
                Parameter channelProperties = ((AtomicWirelessChannel) channel).defaultProperties;
View Full Code Here

            if (!(container instanceof CompositeActor)) {
                throw new IllegalActionException(this, "No controller found.");
            }

            CompositeActor cont = (CompositeActor) container;
            Entity entity = cont.getEntity(name);

            if (entity == null) {
                throw new IllegalActionException(this, "No controller found "
                        + "with name " + name);
            }
View Full Code Here

        CompositeActor container = (CompositeActor) getContainer();
        StringBuffer changeMoML = new StringBuffer("<group>\n");
        Iterator actors = container.deepEntityList().iterator();

        while (actors.hasNext()) {
            Entity node = (Entity) actors.next();

            // Skip actors that are not properly marked.
            Attribute mark = node.getAttribute("randomize");

            if (!(mark instanceof Variable)) {
                continue;
            }
View Full Code Here

        oldList.addAll(rateVariables);

        LinkedList newList = new LinkedList();
        for (Iterator entities = model.deepEntityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();

            for (Iterator ports = entity.portList().iterator(); ports.hasNext();) {
                Port port = (Port) ports.next();
                Set set = analysis.getNotConstVariables(port);
                Variable variable;
                variable = DFUtilities.getRateVariable(port,
                        "tokenInitProduction");
View Full Code Here

            count = 0;
            for (Iterator actors = reachedActorList.iterator(); actors
                    .hasNext()
                    && count < 100; count++) {
                Entity entity = (Entity) actors.next();
                messageBuffer.append(entity.getFullName() + " ");
            }

            if (count >= 99) {
                messageBuffer.append("...");
            }
View Full Code Here

                            + "code generation, then you might "
                            + "consider setting the allowRateChanges "
                            + "parameter of the SDF director to false.");
        }

        Entity changeContext = analysis.getChangeContext(variable);

        if (!((changeContext == model) || changeContext.deepContains(model))) {
            throw new IllegalActionException(variable,
                    "The SDF rate parameter changes during "
                            + "execution of the schedule!");
        }
    }
View Full Code Here

                if (_debugging && VERBOSE) {
                    _debug("Actors that can be scheduled:");

                    for (Iterator readyActors = readyToScheduleActorList
                            .iterator(); readyActors.hasNext();) {
                        Entity readyActor = (Entity) readyActors.next();
                        _debug(readyActor.getFullName());
                    }

                    _debug("Actors with firings left:");

                    for (Iterator remainingActors = unscheduledActorList
                            .iterator(); remainingActors.hasNext();) {
                        Entity remainingActor = (Entity) remainingActors.next();
                        _debug(remainingActor.getFullName());
                    }
                }

                // Pick an actor that is ready to fire.
                Actor currentActor = (Actor) readyToScheduleActorList
                        .getFirst();

                // Remove it from the list of actors we are waiting to fire.
                while (readyToScheduleActorList.remove(currentActor)) {
                }

                // Determine the number of times currentActor can fire.
                int numberOfFirings = _computeMaximumFirings(currentActor);

                // We should never schedule something more than the number
                // of times expected by the balance equations.  This might
                // happen because we assume an infinite number of tokens
                // are waiting on external ports.
                int firingsRemaining = ((Integer) firingsRemainingVector
                        .get(currentActor)).intValue();

                if (numberOfFirings > firingsRemaining) {
                    numberOfFirings = firingsRemaining;
                }

                if (_debugging && VERBOSE) {
                    _debug("Scheduling actor " + currentActor.getName() + " "
                            + numberOfFirings + " times.");
                }

                // Update the firingsRemainingVector for this actor.
                firingsRemaining -= numberOfFirings;
                firingsRemainingVector.put(currentActor, Integer
                        .valueOf(firingsRemaining));

                if (_debugging && VERBOSE) {
                    _debug(currentActor.getName() + " should fire "
                            + firingsRemaining + " more times.");
                }

                // Simulate the tokens that are consumed by the actors
                // input ports.
                _simulateInputConsumption(currentActor, numberOfFirings);

                // Add it to the schedule numberOfFirings times.
                Firing firing = new Firing();
                firing.setActor(currentActor);
                firing.setIterationCount(numberOfFirings);
                newSchedule.add(firing);

                // Get all its outputPorts
                // and simulate the proper production of tokens.
                for (Iterator outputPorts = (currentActor).outputPortList()
                        .iterator(); outputPorts.hasNext();) {
                    IOPort outputPort = (IOPort) outputPorts.next();

                    int count = DFUtilities.getTokenProductionRate(outputPort);

                    _simulateTokensCreated(outputPort, count * numberOfFirings,
                            unscheduledActorList, readyToScheduleActorList);
                }

                // Figure out what to do with the actor, now that it has been
                // scheduled.
                if (firingsRemaining < 0) {
                    // If we screwed up somewhere, and fired this more
                    // times than we thought we should have
                    // then throw an exception.
                    // This should never happen.
                    throw new InternalErrorException("Balance Equation "
                            + "solution does not agree with "
                            + "scheduling algorithm!");
                }

                if (firingsRemaining == 0) {
                    // If we've fired this actor all the
                    // times that it should, then
                    // we get rid of it entirely.
                    if (_debugging && VERBOSE) {
                        _debug("Actor = " + currentActor + " is done firing.");
                    }

                    // Remove the actor from the unscheduledActorList
                    // since we don't need to fire it any more.
                    while (unscheduledActorList.remove(currentActor)) {
                        ;
                    }

                    if (_debugging && VERBOSE) {
                        _debug("Remaining actors:");

                        for (Iterator readyActors = readyToScheduleActorList
                                .iterator(); readyActors.hasNext();) {
                            Entity entity = (Entity) readyActors.next();
                            _debug(entity.getFullName());
                        }
                    }
                } else {
                    // Otherwise the actor still has firings left.
                    // Count the number of unfulfilled inputs.
                    int inputCount = _countUnfulfilledInputs(currentActor,
                            unscheduledActorList, false);

                    // We've already removed currentActor from
                    // readyToSchedule actors, and presumably
                    // fired it until it can be fired no more.
                    // This check is here for robustness...
                    // if the actor can still be scheduled
                    // i.e. all its inputs are satisfied, and it
                    // appears in the unscheduled actors list
                    // then put it on the readyToScheduleActorList.
                    if ((inputCount <= 0)
                            && unscheduledActorList.contains(currentActor)) {
                        readyToScheduleActorList.addFirst(currentActor);
                    }
                }
            }
        } catch (IllegalActionException ex) {
            // This could happen if we call getTokenConsumptionRate on a
            // port that isn't a part of the actor.   This probably means
            // the graph is screwed up, or somebody else is mucking
            // with it.
            throw new InternalErrorException(this, ex,
                    "SDF Scheduler Failed internal consistency check.");
        }

        // If there are any actors left when we're done, then report the
        // error.
        if (unscheduledActorList.size() > 0) {
            StringBuffer message = new StringBuffer(
                    "Actors remain that cannot be scheduled!\n"
                            + "Unscheduled actors:\n");

            // Only display the first 100 connected or disconnected actors.
            int count = 0;
            for (Iterator actors = unscheduledActorList.iterator(); actors
                    .hasNext()
                    && count < 100; count++) {
                Entity entity = (Entity) actors.next();
                message.append(entity.getFullName() + " ");
            }

            if (count >= 99) {
                message.append("...");
            }
            message.append("\nScheduled actors:\n");
            List scheduledActorList = new LinkedList();
            scheduledActorList.addAll(actorList);
            scheduledActorList.removeAll(unscheduledActorList);

            count = 0;

            for (Iterator actors = scheduledActorList.iterator(); actors
                    .hasNext()
                    && count < 100; count++) {
                Entity entity = (Entity) actors.next();
                message.append(entity.getFullName() + " ");
            }

            if (count >= 99) {
                message.append("...");
            }
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.