1 package edu.berkeley.fleet;
3 /** a port which outputs only tokens */
4 public class TokenOutPort extends InstructionPort {
6 private boolean empty = true;
8 public TokenOutPort(Ship ship, String name) {
12 public boolean empty() {
16 public void addToken() {
18 throw new RuntimeException("tried to add data to a non-empty tokenoutbox! you have a buggy ship!");
22 public boolean service(Instruction instruction) {
24 // if no instruction waiting, do nothing
25 if (instruction == null) return false;
27 // check firing conditions
28 if (instruction.trigger)
29 throw new RuntimeException("you cannot send triggered instructions to token-output ports");
31 switch(instruction.dataIn) {
39 Port port = instruction.destination.resolve(getShip().getFleet());
40 Log.token(this, port);
45 public void addData(int data) {
46 throw new RuntimeException("invalid!");