|
From: <jom...@us...> - 2009-03-09 21:42:48
|
Revision: 1460
http://jason.svn.sourceforge.net/jason/?rev=1460&view=rev
Author: jomifred
Date: 2009-03-09 21:42:29 +0000 (Mon, 09 Mar 2009)
Log Message:
-----------
change .plan_label to use 'plan term'
Modified Paths:
--------------
trunk/demos/communication/bob.asl
trunk/src/asl/kqmlPlans.asl
trunk/src/jason/stdlib/add_plan.java
trunk/src/jason/stdlib/plan_label.java
Modified: trunk/demos/communication/bob.asl
===================================================================
--- trunk/demos/communication/bob.asl 2009-03-09 15:33:35 UTC (rev 1459)
+++ trunk/demos/communication/bob.asl 2009-03-09 21:42:29 UTC (rev 1460)
@@ -49,8 +49,8 @@
.println("Asking Maria to unachieve 'hello'");
.send(maria,unachieve, hello(bob));
- // send untell how to maria
- .send(maria,untellHow,hp).
+ // send untell how to maria
+ .send(maria,untellHow,hp).
+vl(X)[source(A)]
Modified: trunk/src/asl/kqmlPlans.asl
===================================================================
--- trunk/src/asl/kqmlPlans.asl 2009-03-09 15:33:35 UTC (rev 1459)
+++ trunk/src/asl/kqmlPlans.asl 2009-03-09 21:42:29 UTC (rev 1460)
@@ -112,5 +112,11 @@
// the triggering event
@kqmlReceivedAskHow
+!kqml_received(Sender, askHow, Content, MsgId)
- <- .relevant_plans(Content, ListAsString);
- .send(Sender, tellHow, ListAsString, MsgId).
+ <- .relevant_plans(Content, ListOfPlans);
+ .send(Sender, tellHow, ListOfPlans, MsgId).
+
+/* general communication error handler */
+
+@kqmlError
+-!kqml_received(Sender, Per, Content, MsgId)[error(EID), error_msg(EMsg)]
+ <- .print("Communication error -- ",EID, ": ", EMsg).
Modified: trunk/src/jason/stdlib/add_plan.java
===================================================================
--- trunk/src/jason/stdlib/add_plan.java 2009-03-09 15:33:35 UTC (rev 1459)
+++ trunk/src/jason/stdlib/add_plan.java 2009-03-09 21:42:29 UTC (rev 1460)
@@ -32,6 +32,7 @@
import jason.asSyntax.Plan;
import jason.asSyntax.StringTerm;
import jason.asSyntax.Term;
+import jason.asSyntax.VarTerm;
import jason.asSyntax.parser.ParseException;
import jason.bb.BeliefBase;
@@ -134,8 +135,10 @@
p = ASSyntax.parsePlan(sPlan);
} else if (t instanceof Plan) {
p = (Plan)t;
+ } else if (t instanceof VarTerm && ((VarTerm)t).hasValue() && ((VarTerm)t).getValue() instanceof Plan) {
+ p = (Plan)((VarTerm)t).getValue();
} else {
- throw JasonException.createWrongArgument(this, "The term '"+t+"' can not be used as a plan for .add_plan.");
+ throw JasonException.createWrongArgument(this, "The term '"+t+"' ("+t.getClass().getSimpleName()+") can not be used as a plan for .add_plan.");
}
return p;
Modified: trunk/src/jason/stdlib/plan_label.java
===================================================================
--- trunk/src/jason/stdlib/plan_label.java 2009-03-09 15:33:35 UTC (rev 1459)
+++ trunk/src/jason/stdlib/plan_label.java 2009-03-09 21:42:29 UTC (rev 1460)
@@ -28,18 +28,19 @@
import jason.asSemantics.TransitionSystem;
import jason.asSemantics.Unifier;
import jason.asSyntax.Plan;
-import jason.asSyntax.StringTermImpl;
import jason.asSyntax.Term;
/**
<p>Internal action: <b><code>.plan_label(<i>P</i>,<i>L</i>)</code></b>.
- <p>Description: unifies <i>P</i> with a string representing the plan
+ <p>Description: unifies <i>P</i> with a <i>plan term</i> representing the plan
labeled with the term <i>L</i> within the agent's plan library.
<p>Parameters:<ul>
- <li>- plan (string): the string representing the plan.<br/>
+ <li>- plan (plan term): the term representing the plan, it is
+ a plan enclosed by { and }
+ (e.g. <code>{+!g : vl(X) <- .print(X)}</code>).<br/>
<li>+ label (structure): the label of that plan.<br/>
@@ -47,8 +48,8 @@
<p>Example:<ul>
- <li> <code>.plan_label(P,p1)</code>: unifies P with the string
- representation of the plan labelled <code>p1</code>.</li>
+ <li> <code>.plan_label(P,p1)</code>: unifies P with the term
+ representation of the plan labeled <code>p1</code>.</li>
</ul>
@@ -78,8 +79,9 @@
if (p != null) {
p = (Plan)p.clone();
p.getLabel().delSources();
- String ps = p.toASString().replaceAll("\"", "\\\\\"");
- return un.unifies(new StringTermImpl(ps), args[0]);
+ //String ps = p.toASString().replaceAll("\"", "\\\\\"");
+ //return un.unifies(new StringTermImpl(ps), args[0]);
+ return un.unifies(p, args[0]);
} else {
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|