Package ptolemy.actor.sched

Examples of ptolemy.actor.sched.NotSchedulableException


            } else {
                CTReceiver.SignalType previousType = (CTReceiver.SignalType) _map
                        .get(port);

                if (previousType != type) {
                    throw new NotSchedulableException(port.getFullName()
                            + " has a signal type conflict: \n"
                            + "Its signal type was set/resolved to "
                            + signalTypeToString(previousType)
                            + ", but is going to be set to "
                            + signalTypeToString(type) + " now.");
View Full Code Here


                            String propagateType = signalTypeToString(getType(port));

                            if ((configuredType.compareToIgnoreCase("UNKNOWN") != 0)
                                    && (propagateType
                                            .compareToIgnoreCase(configuredType) != 0)) {
                                throw new NotSchedulableException(
                                        "Signal type conflict: "
                                                + port.getFullName()
                                                + " (of type "
                                                + configuredType
                                                + ") and "
                                                + nextPort.getFullName()
                                                + " (of type "
                                                + propagateType
                                                + ")"
                                                + "). Perhaps the connection has "
                                                + "sequence semantics?");
                            }
                        } catch (IllegalActionException e) {
                            throw new NotSchedulableException(
                                    "The signal"
                                            + " type parameter does not contain a valid"
                                            + " value.");
                        }
                    }

                    setType(nextPort, getType(port));
                } else if (getType(port) != getType(nextPort)) {
                    LinkedList offendingPorts = new LinkedList();
                    offendingPorts.add(port);
                    offendingPorts.add(nextPort);
                    throw new NotSchedulableException(offendingPorts, null,
                            "Signal type conflict: " + port.getFullName()
                                    + " (of type "
                                    + signalTypeToString(getType(port))
                                    + ") and " + nextPort.getFullName()
                                    + " (of type "
View Full Code Here

                //    + port.getFullName() + " to port "
                //    + nextPort.getFullName());
                if (!_map.containsKey(nextPort)) {
                    setType(nextPort, getType(port));
                } else if (getType(port) != getType(nextPort)) {
                    throw new NotSchedulableException("Signal type conflict: "
                            + port.getFullName() + " (of type "
                            + signalTypeToString(getType(port)) + ") and "
                            + nextPort.getFullName() + " (of type "
                            + signalTypeToString(getType(nextPort)) + ")"
                            + "). Perhaps the connections has "
View Full Code Here

        Token token = director.vectorizationFactor.getToken();
        vectorizationFactor = ((IntToken) token).intValue();
        //}

        if (vectorizationFactor < 1) {
            throw new NotSchedulableException(this,
                    "The supplied vectorizationFactor must be "
                            + "a positive integer. " + "The given value was: "
                            + vectorizationFactor);
        }
View Full Code Here

                    .hasNext();) {
                Entity entity = (Entity) actors.next();
                string.append(entity.getFullName() + "\n");
            }

            throw new NotSchedulableException(string.toString());
        }

        if (_debugging) {
            _debug("Schedule is:");
            _debug(newSchedule.toString());
View Full Code Here

            // Now resolve signal types to find the continuous and
            // discrete clusters of actors.
            if (a instanceof SequenceActor) {
                // Set all ports of a sequence actor with signal type "DISCRETE"
                if (predecessorList(a).isEmpty()) {
                    throw new NotSchedulableException(((Nameable) a).getName()
                            + " is a SequenceActor, which cannot be a"
                            + " source actor in the CT domain.");
                }

                Iterator ports = ((Entity) a).portList().iterator();

                while (ports.hasNext()) {
                    IOPort port = (IOPort) ports.next();
                    _signalTypeMap.setType(port, DISCRETE);

                    if (port.isOutput()) {
                        _signalTypeMap.propagateType(port);
                    }
                }
            } else if ((a instanceof CompositeActor)
                    && !(a instanceof CTCompositeActor)) {
                // This actor is an opaque composite actor but not a
                // CT Composite actor.
                // NOTE: For its output ports, we can tell the signal type
                // from their receiver types. However, the signal types of
                // its input ports have to be derived from the output ports
                // of some other actors that reside at the same hierarchical
                // level. So we only handle output ports here.
                Iterator ports = ((Entity) a).portList().iterator();

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

                    if (port.isOutput()) {
                        Receiver[][] insideReceivers = port
                                .getInsideReceivers();

                        // NOTE: The assumption is that all the receivers
                        // belonging to the same IO port have the same
                        // signal type, so if there is at least one
                        // receiver, then use its type. If there are no
                        // receivers, assume the type is continuous.
                        if (insideReceivers.length > 0
                                && insideReceivers[0] != null
                                && insideReceivers[0].length > 0) {
                            Receiver insideReceiver = insideReceivers[0][0];

                            if (insideReceiver instanceof StateReceiver) {
                                _signalTypeMap.setType(port, CONTINUOUS);
                            } else {
                                _signalTypeMap.setType(port, DISCRETE);
                            }
                        } else {
                            _signalTypeMap.setType(port, CONTINUOUS);
                        }

                        _signalTypeMap.propagateType(port);
                    }
                }
            } else {
                // The signal types of the rest ports are obtained
                // from the "signalType" parameter.
                Iterator ports = ((Entity) a).portList().iterator();

                while (ports.hasNext()) {
                    IOPort port = (IOPort) ports.next();
                    Parameter signalType = (Parameter) port
                            .getAttribute("signalType");

                    if (signalType != null) {
                        String type = ((StringToken) signalType.getToken())
                                .stringValue();
                        type = type.trim().toUpperCase();

                        if (type.equals("CONTINUOUS")) {
                            _signalTypeMap.setType(port, CONTINUOUS);

                            if (port.isOutput()) {
                                _signalTypeMap.propagateType(port);
                            }
                        } else if (type.equals("DISCRETE")) {
                            _signalTypeMap.setType(port, DISCRETE);

                            if (port.isOutput()) {
                                _signalTypeMap.propagateType(port);
                            }
                        } else {
                            throw new InvalidStateException(port,
                                    " signalType not understandable.");
                        }
                    } else if (a instanceof CTCompositeActor) {
                        // Assume all the ports of a CTCompositeActor
                        // to be continuous unless otherwise specified.
                        // NOTE: this is a conservative approximation.
                        if (_signalTypeMap.getType(port) == UNKNOWN) {
                            _signalTypeMap.setType(port, CONTINUOUS);
                        }

                        if (port.isOutput()) {
                            _signalTypeMap.propagateType(port);
                        }
                    }
                }

                // NOTE: If it is a domain polymorphic source, unless its
                // outputs are declared as DISCRETE, assume their signal
                // types to CONTINUOUS. For example, the Const actor.
                // FIXME: Should the Sequence actor implement the SequenceActor
                // interface?
                if (predecessorList(a).isEmpty()) {
                    ports = ((Entity) a).portList().iterator();

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

                        if (_signalTypeMap.getType(port) == UNKNOWN) {
                            _signalTypeMap.setType(port, CONTINUOUS);

                            if (port.isOutput()) {
                                _signalTypeMap.propagateType(port);
                            }
                        }
                    }
                }
            }
        }

        // Done with classification and port signal type assignment
        // of the sources, waveform generators, event generators,
        // sequence actors, and dynamic actors.
        // In the following, we first try to resolve the signal types of
        // the ports of the rest actors including nonCTSubsystems
        // by propagating known signal types.
        // First make sure that there is no causality loop of arithmetic
        // actors. This makes the graph reachability algorithms terminate.
        DirectedAcyclicGraph arithmeticGraph = _toGraph(arithmeticActors);

        if (!arithmeticGraph.isAcyclic()) {
            Object[] cycleNodes = arithmeticGraph.cycleNodes();
            LinkedList nodesAsList = new LinkedList();
            StringBuffer inCycle = new StringBuffer("Cycle includes: ");
            for (int i = 0; i < cycleNodes.length; i++) {
                inCycle.append(((NamedObj) cycleNodes[i]).getFullName());
                if (i < cycleNodes.length - 1) {
                    inCycle.append(", ");
                }
                nodesAsList.add(cycleNodes[i]);
            }
            throw new NotSchedulableException(nodesAsList, null,
                    "Algebraic loop. " + inCycle.toString());
        }

        // We do not allow loops of dynamic actors, either.
        DirectedAcyclicGraph dynamicGraph = _toGraph(dynamicActors);

        // FIXME: Why is this disallowed? If we change this, change the class
        // comment (at the end) also.
        if (!dynamicGraph.isAcyclic()) {
            throw new NotSchedulableException(
                    "Loops of dynamic actors (e.g. integrators) "
                            + "are not allowed in the CT domain. You may insert a "
                            + "Scale actor with factor 1.");
        }

        // Now we propagate the signal types by topological sort.
        // Notice that signal types of the output ports of the dynamic actors,
        // source actors, waveform generators, event generators, and sequence
        // actors have already been propagated by one step.
        // So, we start with arithmetic actors.
        Object[] sortedArithmeticActors = arithmeticGraph.topologicalSort();

        for (int i = 0; i < sortedArithmeticActors.length; i++) {
            Actor actor = (Actor) sortedArithmeticActors[i];

            // Note that the signal type of the input ports should be set
            // already. If all input ports are CONTINUOUS, and the
            // output ports are UNKNOWN, then all output ports should be
            // CONTINUOUS. If all input ports are DISCRETE, and the
            // output ports are UNKNOWN, then all output ports should be
            // DISCRETE. If some input ports are continuous and some
            // input ports are discrete, then the output port type must
            // be set manually, which means they can not been resolved.
            Iterator inputPorts = actor.inputPortList().iterator();
            CTReceiver.SignalType knownInputType = UNKNOWN;
            boolean needManuallySetType = true;

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

                if (inputPort.getWidth() != 0) {
                    CTReceiver.SignalType inputType = _signalTypeMap
                            .getType(inputPort);

                    if (inputType == UNKNOWN) {
                        throw new NotSchedulableException("Cannot resolve "
                                + "signal type for port "
                                + inputPort.getFullName()
                                + ". If you are certain about the signal type"
                                + ", you can set them manually.\n"
                                + " To do this, you can add a parameter "
                                + "called \'signalType\' with value "
                                + "\'\"CONTINUOUS\"\' or \'\"DISCRETE\"\'"
                                + " to a port.");
                    } else if (knownInputType == UNKNOWN) {
                        knownInputType = inputType;
                        needManuallySetType = false;
                    } else if (knownInputType != inputType) {
                        needManuallySetType = true;
                        break;
                    }
                }
            }

            Iterator outputPorts = actor.outputPortList().iterator();

            while (outputPorts.hasNext()) {
                IOPort outputPort = (IOPort) outputPorts.next();

                if (outputPort.getWidth() != 0) {
                    CTReceiver.SignalType outputType = _signalTypeMap
                            .getType(outputPort);

                    if (outputType == UNKNOWN) {
                        if (needManuallySetType) {
                            throw new NotSchedulableException(
                                    "Cannot resolve "
                                            + "signal type for port "
                                            + outputPort.getFullName()
                                            + ".\n To set the signal type manually, "
                                            + "add a parameter with name \'signalType\'"
View Full Code Here

     @see #setRate
     */
    public static int getRate(IOPort port) throws NotSchedulableException,
            IllegalActionException {
        if (port.isInput() && port.isOutput()) {
            throw new NotSchedulableException(port,
                    "Port is both an input and an output, which is not"
                            + " allowed in SDF.");
        } else if (port.isInput()) {
            return getTokenConsumptionRate(port);
        } else if (port.isOutput()) {
            return getTokenProductionRate(port);
        } else {
            throw new NotSchedulableException(port,
                    "Port is neither an input and an output, which is not"
                            + " allowed in SDF.");
        }
    }
View Full Code Here

                .getContainer());
        List actorList = compositeActor.deepEntityList();
        int actorCount = actorList.size();

        if (actorCount < 1) {
            throw new NotSchedulableException(
                    this,
                    "Could not get schedule, "
                            + "the number of deeply contained entities for '"
                            + compositeActor.getFullName()
                            + "' is "
                            + actorCount
                            + ", which is less than 1."
                            + "If you have empty composite actors, try adding an  actor"
                            + "to the inside of one of the empty composite actors.");
        }

        int[] frequencyArray = new int[actorCount];
        int[] intervalArray = new int[actorCount];

        ListIterator actorListIterator = actorList.listIterator();

        int i = 0;
        int biggestFrequency = _candidateFrequencies[_candidateFrequencies.length - 1];

        while (actorListIterator.hasNext()) {
            Actor actor = (Actor) actorListIterator.next();
            int frequency = getFrequency(actor);

            if (Arrays.binarySearch(_candidateFrequencies, frequency) >= 0) {
                // this frequency is a good candidate to calculate accurate
                // _unitTimeIncrement for the director.
                frequencyArray[i] = frequency;
                i++;
            } else if (frequency > biggestFrequency) {
                throw new NotSchedulableException(
                        this,
                        "The specified frequency "
                                + frequency
                                + " is bigger than the allowed biggest "
                                + "frequency "
                                + biggestFrequency
                                + ". \n Try "
                                + "introducing hierarchies or reducing the period "
                                + "parameter of the director to achieve shorter "
                                + "execution time.");
            } else {
                throw new NotSchedulableException(
                        this,
                        "Cannot assign a frequency "
                                + frequency
                                + " to "
                                + actor.getName()
View Full Code Here

TOP

Related Classes of ptolemy.actor.sched.NotSchedulableException

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.