1 package at.ac.tuwien.sbc.valesriegler.xvsm.waiter;
3 import at.ac.tuwien.sbc.valesriegler.common.Tuple;
4 import at.ac.tuwien.sbc.valesriegler.common.Util;
5 import at.ac.tuwien.sbc.valesriegler.xvsm.WaiterXVSM;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
9 import java.io.Serializable;
12 * This is a waiter using XVSM
14 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
17 public class Waiter implements Serializable {
18 private static final String USAGE = "Waiter needs exactly two integer parameters: WAITERID, PIZZERIA-SPACE-PORT";
19 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
21 private final int port;
23 private WaiterXVSM xvsm;
25 public static void main(String[] args) {
26 final Tuple<Integer> waiterIdAndSpacePort = Util.parseIdAndSpacePort(args, USAGE);
28 Waiter waiter = new Waiter(waiterIdAndSpacePort.fst, waiterIdAndSpacePort.snd);
32 private void start() {
33 xvsm = new WaiterXVSM(id, port);
35 xvsm.listenForOrderRequests();
37 xvsm.listenForPaymentRequest();
39 xvsm.listenForPreparedPizzas();
41 // when new guests arrive the waiter should try to assign a table to them
42 xvsm.listenForNewGuests();
44 // when tables get free the waiter should have a look if there are waiting guests and assign the new table to them
45 xvsm.listenForFreeTable();
47 xvsm.listenForPhoneOrders();
51 public Waiter(int id, int port) {
54 log.info("I AM A WAITER WITH ID {}", id);