From b8f2687296ad47626412e2a54f4916f7fabc4d6d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 29 May 2008 13:55:34 +0000 Subject: Only relevant message delivering works. --- sources/core/VSMessage.java | 26 +++++++++++++++++++++++++- sources/core/VSProcess.java | 4 ++-- sources/core/VSTask.java | 26 +++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) (limited to 'sources/core') diff --git a/sources/core/VSMessage.java b/sources/core/VSMessage.java index 663abbc..25dbf27 100644 --- a/sources/core/VSMessage.java +++ b/sources/core/VSMessage.java @@ -18,6 +18,17 @@ public class VSMessage extends VSPrefs { /** The serial version uid */ private static final long serialVersionUID = 1L; + /** The constant IS_SERVER_MESSAGE. */ + public static final boolean IS_SERVER_MESSAGE = true; + + /** The constant IS_CLIENT_MESSAGE. */ + public static final boolean IS_CLIENT_MESSAGE = false; + + /** true, if the message has been sent from a server. false, if the message + * has been sent from a client. + */ + private boolean isServerMessage; + /** Each message belongs to a specific protocol. This variable defined the * class name of the protocol being used. */ @@ -61,10 +72,13 @@ public class VSMessage extends VSPrefs { * * @param process The sending process of this message. * @param protocolClassname The classname of the protocol this message. + * @param isServerMessage Sets if the message has been sent by a server. */ - public void init(VSProcess process, String protocolClassname) { + public void init(VSProcess process, String protocolClassname, + boolean isServerMessage) { this.sendingProcess = process; this.protocolClassname = protocolClassname; + this.isServerMessage = isServerMessage; this.prefs = process.getPrefs(); lamportTime = sendingProcess.getLamportTime(); @@ -125,6 +139,16 @@ public class VSMessage extends VSPrefs { return vectorTime; } + /** + * Checks if the message has been sent by a server or a client. + * + * @return true, if the message has been sent by a server. false, if the + * message has been sent by a clien. + */ + public boolean isServerMessage() { + return isServerMessage; + } + /* (non-Javadoc) * @see prefs.VSPrefs#toString() */ diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index 7071ae2..73ba679 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -886,7 +886,7 @@ public class VSProcess extends VSPrefs { * * @return the simulation canvas */ - public VSSimulatorCanvas getSimulationCanvas() { + public VSSimulatorCanvas getSimulatorCanvas() { return simulationCanvas; } @@ -915,7 +915,7 @@ public class VSProcess extends VSPrefs { * * @param index the index the process has to get removed. */ - public void removeProcessAtIndex(int index) { + public void removedAProcessAtIndex(int index) { if (index < processNum) --processNum; diff --git a/sources/core/VSTask.java b/sources/core/VSTask.java index 0bc0d3f..1e3958d 100644 --- a/sources/core/VSTask.java +++ b/sources/core/VSTask.java @@ -45,6 +45,12 @@ public class VSTask implements Comparable { /** The simulation's default prefs. */ private VSPrefs prefs; + /** The message line, which gets drawn by the simulation canvas. this + * reference is needed here in order to remove the message line from + * the painting area if the message is not relevant + */ + private simulator.VSSimulatorCanvas.VSMessageLine messageLine; + /** The task is programmed. The task will be still in the task manager * after reset. */ @@ -188,13 +194,31 @@ public class VSTask implements Comparable { return process; } + /** + * Sets the message line. + * + * @messageLine the message line + */ + public void setMessageLine(simulator.VSSimulatorCanvas.VSMessageLine + messageLine) { + this.messageLine = messageLine; + } + /** * Runs the task. */ public void run() { if (event.getProcess() == null) event.init(process); - event.onStart(); + + if (messageLine != null) { + System.out.println("FO"); + if (!event.onStart()) + process.getSimulatorCanvas().removeMessageLine(messageLine); + } else { + System.out.println("BA"); + event.onStart(); + } } /** -- cgit v1.2.3