From d91608f592cc8b5817473b75e5024f7eecd7262a Mon Sep 17 00:00:00 2001 From: Gregor Riegler Date: Mon, 10 Jun 2013 20:38:34 +0200 Subject: [PATCH] [XVSM] Some simulation improvments, documentation --- README.md | 25 +++++++++++-------- .../tuwien/sbc/valesriegler/common/Util.java | 2 +- .../valesriegler/group/gui/GroupFrame.java | 13 +++++----- .../pizzeria/gui/PizzeriaFrame.java | 4 +++ .../sbc/valesriegler/xvsm/CookXVSM.java | 24 +++++++++--------- .../sbc/valesriegler/xvsm/DriverXVSM.java | 2 +- .../sbc/valesriegler/xvsm/GroupAgentXVSM.java | 4 +-- 7 files changed, 41 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index b57d2b4..f79e5bf 100644 --- a/README.md +++ b/README.md @@ -12,18 +12,21 @@ Space Based Computing SS 2013 ### How to start a JMS Cook with Id 1 mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.jms.cook.Cook" -Dexec.args="1" -### How to start a Space Server - mvn exec:java -Dexec.mainClass="org.mozartspaces.core.Server" -Dexec.args= - -### How to start the Space Group GUI + +XVSM +---- + +### 1. Start the Group Space Server + mvn exec:java -Dexec.mainClass="org.mozartspaces.core.Server" -Dexec.args=9876 + +### 2. Start the Group Space GUI mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.group.GroupAgent" -Dexec.args="XVSM" -The Group GUI expects that a Space Server was started on 9876. -### How to start the Space Pizzeria GUI +### Start a Pizzeria GUI mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent" -Dexec.args="XVSM " - -### How to start a Space Waiter with Id 1 + +### Start a Space Waiter mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="1 " - -### How to start a Space Cook with Id 1 - mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 " \ No newline at end of file + +### Start a Space Cook + mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 " diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java index 36d52c0..4f200e8 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java @@ -42,7 +42,7 @@ public abstract class Util { public static final String DELIVERY_PROGRESS = "deliveryInProgress"; public static final String DELIVERY_DONE = "deliveryDone"; - public static final boolean runSimulation = false; + public static final boolean runSimulation = true; public static final String NUMBER_DISPLAY_FORMAT = String.format("%%0%dd", 3); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupFrame.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupFrame.java index a32f12f..0bb4347 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupFrame.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/gui/GroupFrame.java @@ -1,14 +1,11 @@ package at.ac.tuwien.sbc.valesriegler.group.gui; -import java.awt.GridLayout; - -import javax.swing.JFrame; -import javax.swing.JPanel; - +import at.ac.tuwien.sbc.valesriegler.common.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.ac.tuwien.sbc.valesriegler.common.Util; +import javax.swing.*; +import java.awt.*; /** * Base Frame of the Group UI @@ -41,6 +38,10 @@ public class GroupFrame extends JFrame { setContentPane(wrapper); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + this.setMaximizedBounds(env.getMaximumWindowBounds()); + this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH); } private void initGroupOverview(JPanel wrapper, GroupOverviewModel groupModel) { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/PizzeriaFrame.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/PizzeriaFrame.java index 54bbf23..0680842 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/PizzeriaFrame.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/pizzeria/gui/PizzeriaFrame.java @@ -71,6 +71,10 @@ public class PizzeriaFrame extends JFrame { setContentPane(wrapper); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); + this.setMaximizedBounds(env.getMaximumWindowBounds()); + this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH); + initModels(); } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java index 5f7154c..eca7a70 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java @@ -71,15 +71,15 @@ public class CookXVSM extends AbstractXVSMConnector { notifyCustomerPizzaDone(pizza, tx); capi.commitTransaction(tx); - log.debug("I have completed preparing a pizza for order {}!", pizza.getOrderId()); +// log.debug("I have completed preparing a pizza for order {}!", pizza.getOrderId()); } catch (NullPointerException e) { // the strange nullpointer exception from the space } catch (EntityNotFoundByTemplate e) { - log.info("entitynotfound: {}", e.getMessage()); +// log.info("entitynotfound: {}", e.getMessage()); } catch (Exception e) { - log.info("outer cook"); - log.info(e.getMessage()); - e.printStackTrace(); +// log.info("outer cook"); +// log.info(e.getMessage()); +// e.printStackTrace(); } } @@ -140,12 +140,12 @@ public class CookXVSM extends AbstractXVSMConnector { } catch (NullPointerException e) { // the strange nullpointer exception from the space } catch (EntityNotFoundByTemplate e) { - log.info("entitynotfound: {}", e.getMessage()); +// log.info("entitynotfound: {}", e.getMessage()); } catch (Exception e) { - log.info("outer cook"); - log.info(e.getMessage()); - e.printStackTrace(); +// log.info("outer cook"); +// log.info(e.getMessage()); +// e.printStackTrace(); } } @@ -232,7 +232,7 @@ public class CookXVSM extends AbstractXVSMConnector { } sendItemsToContainer(Arrays.asList(groupFromSpace), pizzeriaDeliveryContainer, RequestTimeout.DEFAULT, inPreparationTx); sendItemsToContainer(Arrays.asList(pizzaInProgress), pizzaInProgressContainer, RequestTimeout.DEFAULT, inPreparationTx); - log.info("before inprogress comit!"); +// log.info("before inprogress comit!"); capi.commitTransaction(inPreparationTx); } @@ -257,8 +257,8 @@ public class CookXVSM extends AbstractXVSMConnector { sendItemsToContainer(Arrays.asList(pizzaInProgress), pizzaInProgressContainer, RequestTimeout.DEFAULT, inPreparationTx); capi.commitTransaction(inPreparationTx); } catch (Exception e) { - log.error("This error has occurred: {}", e.getMessage()); - e.printStackTrace(); +// log.error("This error has occurred: {}", e.getMessage()); +// e.printStackTrace(); } } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java index 349b059..49196e0 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java @@ -63,7 +63,7 @@ public class DriverXVSM extends AbstractXVSMConnector { try { // Get lock for delivering this delivery order - final DeliveryGroupData deliveryGroup = takeMatchingEntity(template, deliverDeliveryOrderContainer, tx, MzsConstants.RequestTimeout.DEFAULT, error); + takeMatchingEntity(template, deliverDeliveryOrderContainer, tx, MzsConstants.RequestTimeout.DEFAULT, error); final DeliveryGroupData group = takeMatchingEntity(template, pizzeriaDeliveryContainer, tx, MzsConstants.RequestTimeout.INFINITE, "Cannot get the delivery order!"); group.setDriverId(driverId); group.setDeliveryStatus(DeliveryStatus.IN_PROGRESS); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java index c42b0a2..17eddeb 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/GroupAgentXVSM.java @@ -133,13 +133,13 @@ public class GroupAgentXVSM extends AbstractXVSMConnector { List groups3 = GroupAgent.getInstance().createGroups(pizzaTypes3, pizzeria2, 2); final DeliveryOverviewModel deliveryModel = GroupAgent.getInstance().getDeliveryModel(); -// deliveryModel.addItems(groups1); + deliveryModel.addItems(groups1); deliveryModel.addItems(groups2); deliveryModel.addItems(groups3); GroupAgent.getInstance().onDeliveryGroupsCreated(groups2); GroupAgent.getInstance().onDeliveryGroupsCreated(groups3); -// GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); + GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); log.info("ATTENTION: Now let's wait 60 seconds!"); -- 2.43.0