1 package at.ac.tuwien.sbc.valesriegler.xvsm.waiter;
3 import java.io.Serializable;
5 import at.ac.tuwien.sbc.valesriegler.common.Tuple;
6 import at.ac.tuwien.sbc.valesriegler.common.Util;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
10 import at.ac.tuwien.sbc.valesriegler.xvsm.WaiterXVSM;
13 * This is a waiter using XVSM
15 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
18 public class Waiter implements Serializable {
19 private static final String USAGE = "Waiter needs exactly two integer parameters: WAITERID, PIZZERIA-SPACE-PORT";
20 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
22 private final int port;
24 private WaiterXVSM xvsm;
26 public static void main(String[] args) {
27 final Tuple<Integer> waiterIdAndSpacePort = Util.parseIdAndSpacePort(args, USAGE);
29 Waiter waiter = new Waiter(waiterIdAndSpacePort.fst, waiterIdAndSpacePort.snd);
33 private void start() {
34 xvsm = new WaiterXVSM(id, port);
36 xvsm.listenForOrderRequests();
38 xvsm.listenForPaymentRequest();
40 xvsm.listenForPreparedPizzas();
42 // when new guests arrive the waiter should try to assign a table to them
43 xvsm.listenForNewGuests();
45 // when tables get free the waiter should have a look if there are waiting guests and assign the new table to them
46 xvsm.listenForFreeTable();
48 xvsm.listenForPhoneOrders();
50 xvsm.listenForPreparedDeliveryPizzas();
54 public Waiter(int id, int port) {
57 log.info("I AM A WAITER WITH ID {}", id);