/** * Return the schedule. This method attempts to construct a schedule based on a topological sort * of the graph (which uses causality interfaces). If there are cycles, no such sort is possible, * and this method simply returns a schedule that lists the actors in their natural order in the * container, which is the order in which they were created (unless that order has been modified * through "bring to front" or "send to back"). This method should not be called directly, but * rather the getSchedule() method (which is defined in the superclass) will call it when the * schedule is invalid. This method is not synchronized on the workspace. * * @return A schedule. */ @Override protected Schedule _getSchedule() { StaticSchedulingDirector director = (StaticSchedulingDirector) getContainer(); if (director == null) { throw new NotSchedulableException(this, "No director. "); } CompositeActor compositeActor = (CompositeActor) director.getContainer(); if (compositeActor == null) { throw new NotSchedulableException(this, "No container."); } CausalityInterfaceForComposites causality = (CausalityInterfaceForComposites) compositeActor.getCausalityInterface(); List<Actor> sortedActors; try { sortedActors = causality.topologicalSort(); } catch (IllegalActionException ex) { sortedActors = compositeActor.deepEntityList(); } Schedule schedule = new Schedule(); if (_debugging) { _debug("## Schedule generated:"); } for (Actor actor : sortedActors) { Firing firing = new Firing(actor); schedule.add(firing); if (_debugging) { _debug(" - " + actor.getFullName()); } } if (_debugging) { _debug("## End of schedule."); } setValid(true); return schedule; }
protected void _computeActorDepth() throws IllegalActionException { if (_actorDepthVersion == ((NamedObj) _actor).workspace().getVersion()) { return; } super._computeActorDepth(); // Now fix the internal data structures. // First, the equivalence classes. All inputs are equivalent // because of the common dependency on the enable port. Set<IOPort> allInputs = new HashSet<IOPort>(_actor.inputPortList()); for (IOPort input : _equivalenceClasses.keySet()) { _equivalenceClasses.put(input, allInputs); } // Next, fix the forward and backward dependencies. Map<IOPort, Dependency> enableDependents = new HashMap<IOPort, Dependency>(); _forwardDependencies.put(enable, enableDependents); List<IOPort> outputs = _actor.outputPortList(); for (IOPort output : outputs) { enableDependents.put(output, _defaultDependency.oTimesIdentity()); Map<IOPort, Dependency> backward = _reverseDependencies.get(output); if (backward == null) { backward = new HashMap<IOPort, Dependency>(); _reverseDependencies.put(output, backward); } backward.put(enable, _defaultDependency.oTimesIdentity()); } }