double timeValue = getDirector().getModelTime()
.getDoubleValue();
Token[] values = { new ArrayToken(locationArray),
new DoubleToken(timeValue), new IntToken(0) };
Token result = new RecordToken(labels, values);
output.send(0, result);
} else {
// It is the pursuer. Send its parent info to the pursuer.
if (_timeValue > 0.0) {
String[] labels = { "location", "time", "depth" };
Token[] values = { new ArrayToken(_parentLocation),
new DoubleToken(_timeValue),
new IntToken(_parentDepth) };
Token result = new RecordToken(labels, values);
output.send(0, result);
}
}
}
if (input.hasToken(0)) {
//receive message for updating the spanning tree.
RecordToken inputToken = (RecordToken) input.get(0);
if (_debugging) {
_debug("message token received: ");
}
DoubleToken time = (DoubleToken) inputToken.get("time");
IntToken d = (IntToken) inputToken.get("depth");
if ((time.doubleValue() > _timeValue)
|| ((time.doubleValue() == _timeValue) && (d.intValue() < _parentDepth))) {
//the root node may have been changed
//or there is a shorter path.
ArrayToken locationArray = (ArrayToken) inputToken
.get("location");
int length = locationArray.length();
_parentLocation = new DoubleToken[length];
for (int i = 0; i < length; i++) {
_parentLocation[i] = (DoubleToken) locationArray
.getElement(i);
}
_timeValue = time.doubleValue();
_parentDepth = d.intValue();
String[] labels = { "location", "time", "depth" };
Token[] values = { new ArrayToken(_parentLocation),
new DoubleToken(_timeValue), new IntToken(_parentDepth) };
Token result = new RecordToken(labels, values);
output.send(0, result);
}
}
}