summaryrefslogtreecommitdiff
path: root/sources/core
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-29 13:55:34 +0000
committerPaul Buetow <paul@buetow.org>2008-05-29 13:55:34 +0000
commitb8f2687296ad47626412e2a54f4916f7fabc4d6d (patch)
tree247757bbb960ddceb5adefe89df2fd8115107bfc /sources/core
parentcd2024527c84e3e0fd22072a16ac1ff18e6d406d (diff)
Only relevant message delivering works.
Diffstat (limited to 'sources/core')
-rw-r--r--sources/core/VSMessage.java26
-rw-r--r--sources/core/VSProcess.java4
-rw-r--r--sources/core/VSTask.java26
3 files changed, 52 insertions, 4 deletions
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.
*/
@@ -189,12 +195,30 @@ public class VSTask implements Comparable {
}
/**
+ * 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();
+ }
}
/**