Iterator destinations = _destinations.iterator();
Iterator channels = _numbers.iterator();
Iterator parseTrees = _parseTrees.iterator();
while (destinations.hasNext()) {
NamedObj nextDestination = (NamedObj) destinations.next();
// Need to get the next channel even if it's not used.
Integer channel = (Integer) channels.next();
ASTPtRootNode parseTree = (ASTPtRootNode) parseTrees.next();
Token token;
// In MultirateFSMDirector, the initial transition from
// the initial state is taken during preinitialize() if
// the initial state does not have a refinement, therefore
// _scope need to be initialized here. -- Gang
if (_scope == null) {
FSMActor fsmActor = (FSMActor) getContainer()
.getContainer();
_scope = fsmActor.getPortScope();
}
try {
token = _parseTreeEvaluator.evaluateParseTree(parseTree,
_scope);
} catch (IllegalActionException ex) {
// Chain exceptions to get the actor that
// threw the exception.
throw new IllegalActionException(this, ex,
"Expression invalid.");
}
if (nextDestination instanceof IOPort) {
IOPort destination = (IOPort) nextDestination;
try {
if (channel != null) {
if (token == null) {
destination.sendClear(channel.intValue());
if (_debugging) {
_debug(getFullName() + " port: "
+ destination.getName()
+ " channel: " + channel.intValue()
+ ", Clear!");
}
} else {
destination.send(channel.intValue(), token);
if (_debugging) {
_debug(getFullName() + " port: "
+ destination.getName()
+ " channel: " + channel.intValue()
+ ", token: " + token);
}
}
} else {
if (token == null) {
destination.broadcastClear();
if (_debugging) {
_debug(getFullName() + " port: "
+ destination.getName()
+ " broadcast Clear!");
}
} else {
destination.broadcast(token);
if (_debugging) {
_debug(getFullName() + " port: "
+ destination.getName()
+ " broadcast token: " + token);
}
}
}
} catch (NoRoomException ex) {
throw new IllegalActionException(this,
"Cannot complete action: " + ex.getMessage());
} catch (UnknownResultException ex) {
// Produce no output.
}
} else if (nextDestination instanceof Variable) {
Variable destination = (Variable) nextDestination;
try {
//Token token = variable.getToken();
destination.setToken(token);
// Force all dependents to re-evaluate.
// This makes the parameters in the actors of
// the refinement take on new values immediately
// after the action is committed.
destination.validate();
if (_debugging) {
_debug(getFullName() + " variable: "
+ destination.getName() + ", value: "
+ token);
}
} catch (UnknownResultException ex) {
destination.setUnknown(true);
}
} else {
throw new IllegalActionException(this,
"Destination is neither an IOPort nor a Variable: "
+ nextDestination.getFullName());
}
}
}
}