|
From: <jom...@us...> - 2015-03-13 17:23:58
|
Revision: 1824
http://sourceforge.net/p/jason/svn/1824
Author: jomifred
Date: 2015-03-13 17:23:55 +0000 (Fri, 13 Mar 2015)
Log Message:
-----------
fix bug in resume/suspend
Modified Paths:
--------------
trunk/src/jason/stdlib/resume.java
trunk/src/jason/stdlib/suspend.java
trunk/src/jason/stdlib/wait.java
Modified: trunk/src/jason/stdlib/resume.java
===================================================================
--- trunk/src/jason/stdlib/resume.java 2015-03-06 22:09:17 UTC (rev 1823)
+++ trunk/src/jason/stdlib/resume.java 2015-03-13 17:23:55 UTC (rev 1824)
@@ -25,6 +25,7 @@
import jason.JasonException;
import jason.asSemantics.Circumstance;
+import jason.asSemantics.CircumstanceListener;
import jason.asSemantics.DefaultInternalAction;
import jason.asSemantics.Event;
import jason.asSemantics.Intention;
@@ -86,22 +87,30 @@
Iterator<String> ik = C.getPendingIntentions().keySet().iterator();
while (ik.hasNext()) {
String k = ik.next();
- if (k.startsWith(suspend.SUSPENDED_INT)) {
- Intention i = C.getPendingIntentions().get(k);
- if (i.hasTrigger(g, un)) {
- i.setSuspended(false);
+ Intention i = C.getPendingIntentions().get(k);
+ if (i.isSuspended() && i.hasTrigger(g, un)) {
+ i.setSuspended(false);
+ boolean notify = true;
+ if (k.startsWith(suspend.SUSPENDED_INT)) { // if not SUSPENDED_INT, it was suspended while already in PI, so, do not remove it from PI, just change the suspeded status
ik.remove();
- // remove the IA .suspend in case of self-suspend
- if (k.startsWith(suspend.SELF_SUSPENDED_INT))
- i.peek().removeCurrentStep();
-
// add it back in I if not in PA
- if (! C.getPendingActions().containsKey(i.getId()))
+ if (! C.getPendingActions().containsKey(i.getId())) {
C.resumeIntention(i);
-
- //System.out.println("res "+g+" from I "+i.getId());
+ notify = false; // the resumeIntention already notifies
+ }
}
+
+ // notify meta event listeners
+ if (notify && C.getListeners() != null)
+ for (CircumstanceListener el : C.getListeners())
+ el.intentionResumed(i);
+
+ // remove the IA .suspend in case of self-suspend
+ if (k.startsWith(suspend.SELF_SUSPENDED_INT))
+ i.peek().removeCurrentStep();
+
+ //System.out.println("res "+g+" from I "+i.getId());
}
}
Modified: trunk/src/jason/stdlib/suspend.java
===================================================================
--- trunk/src/jason/stdlib/suspend.java 2015-03-06 22:09:17 UTC (rev 1823)
+++ trunk/src/jason/stdlib/suspend.java 2015-03-13 17:23:55 UTC (rev 1824)
@@ -184,7 +184,6 @@
*/
}
- // TODO: consider the case of suspending something that is already suspended.
return true;
}
Modified: trunk/src/jason/stdlib/wait.java
===================================================================
--- trunk/src/jason/stdlib/wait.java 2015-03-06 22:09:17 UTC (rev 1823)
+++ trunk/src/jason/stdlib/wait.java 2015-03-13 17:23:55 UTC (rev 1824)
@@ -24,6 +24,7 @@
package jason.stdlib;
import jason.JasonException;
+import jason.asSemantics.Agent;
import jason.asSemantics.Circumstance;
import jason.asSemantics.CircumstanceListener;
import jason.asSemantics.DefaultInternalAction;
@@ -36,10 +37,10 @@
import jason.asSyntax.NumberTerm;
import jason.asSyntax.NumberTermImpl;
import jason.asSyntax.PlanBody;
+import jason.asSyntax.PlanBody.BodyType;
import jason.asSyntax.PlanBodyImpl;
import jason.asSyntax.Term;
import jason.asSyntax.Trigger;
-import jason.asSyntax.PlanBody.BodyType;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@@ -159,7 +160,7 @@
startTime = System.currentTimeMillis();
if (timeout >= 0) {
- ts.getAg().getScheduler().schedule(new Runnable() {
+ Agent.getScheduler().schedule(new Runnable() {
public void run() {
resume(true);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|