package edu.berkeley.fleet.interpreter;
import edu.berkeley.fleet.api.*;
+import edu.berkeley.sbp.util.ANSI;
class Packet {
return isToken;
}
+ public String toString() {
+ Packet p = this;
+ BitVector data = p.getValue();
+ Dock source = p.getSource();
+ Destination dest = p.getDestination();
+ if (dest.getDock().getInstructionDestination()==dest) {
+ if (p.isToken()) {
+ return (ANSI.yellow(ANSI.bold(" torpedo: ")) + (source + " -> " + ANSI.yellow(ANSI.bold(dest+""))));
+ } else {
+ Instruction d = source.getShip().getFleet().decodeInstruction(data, source);
+ return (ANSI.red("dispatch: " + d));
+ }
+ } else {
+ if (p.isToken()) {
+ return (ANSI.blue(ANSI.bold(" token: ")) + (source + " -> " + ANSI.blue(ANSI.bold(dest+""))));
+ } else {
+ return (ANSI.cyan(" data: "+data) +
+ (source==null ? "" :
+ (" : " + source))+(" -> "+ANSI.cyan(""+dest)));
+ }
+ }
+ }
+
}