1 package at.ac.tuwien.sbc.valesriegler.xvsm.waiter;
3 import java.io.Serializable;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 import at.ac.tuwien.sbc.valesriegler.xvsm.XVSMConnector;
11 * This is a waiter using XVSM
13 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
16 public class Waiter implements Serializable {
17 private static final String USAGE = "Waiter needs exactly one parameter: ID of type Integer";
18 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
21 private XVSMConnector xvsm;
23 public static void main(String[] args) {
24 if (args.length != 1) {
25 throw new IllegalArgumentException(USAGE);
30 parsedId = Integer.parseInt(args[0]);
31 } catch (NumberFormatException e) {
36 Waiter waiter = new Waiter(parsedId);
40 private void start() {
41 initSpaceCommunication();
46 } catch (InterruptedException e) {
50 xvsm.handleWaitingGroup(id);
52 xvsm.handleOrderRequest(id);
54 xvsm.handlePaymentRequest();
56 xvsm.handlePizzaDistribution();
61 private void initSpaceCommunication() {
62 xvsm = new XVSMConnector();
63 xvsm.initSpaceCommunication();
64 xvsm.useTablesContainer();
65 xvsm.useGroupsContainer();
69 public Waiter(int id) {
71 log.info("I AM A WAITER WITH ID {}", id);