|
From: <jom...@us...> - 2015-04-13 20:15:07
|
Revision: 1834
http://sourceforge.net/p/jason/svn/1834
Author: jomifred
Date: 2015-04-13 20:15:05 +0000 (Mon, 13 Apr 2015)
Log Message:
-----------
add parameter to customise kqml events
Modified Paths:
--------------
trunk/release-notes.txt
trunk/src/jason/asSemantics/Agent.java
trunk/src/jason/asSemantics/Message.java
trunk/src/jason/asSemantics/TransitionSystem.java
trunk/src/jason/asSyntax/PlanLibrary.java
trunk/src/jason/jeditplugin/Config.java
Modified: trunk/release-notes.txt
===================================================================
--- trunk/release-notes.txt 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/release-notes.txt 2015-04-13 20:15:05 UTC (rev 1834)
@@ -11,6 +11,11 @@
+ { +b : p <- .print(ok) };
...
+- two new parameters in .jason/user.properties file: kqmlPlansFile (the file
+ with the plans that implement the KQML semantics) and kqmlReceivedFunctor
+ (the functor used to produce new message events).
+
+
New internal actions:
- .asserta: insert a belief (or rule) in the begin of the belief base (can be used in prolog like rules)
- .assertz: insert a belief (or rule) in the end of the belief base (can be used in prolog like rules)
Modified: trunk/src/jason/asSemantics/Agent.java
===================================================================
--- trunk/src/jason/asSemantics/Agent.java 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/src/jason/asSemantics/Agent.java 2015-04-13 20:15:05 UTC (rev 1834)
@@ -208,14 +208,29 @@
fixAgInIAandFunctions(this); // used to fix agent reference in functions used inside includes
}
- // kqml Plans at the end of the ag PS
- if (JasonException.class.getResource("/asl/kqmlPlans.asl") != null) {
- setASLSrc("kqmlPlans.asl");
- parseAS(JasonException.class.getResource("/asl/kqmlPlans.asl"));
- setASLSrc(asSrc);
+ // load kqml plans at the end of the ag PL
+ Config c = Config.get();
+ if (c.getKqmlPlansFile().equals(Message.kqmlDefaultPlans)) {
+ // load default implementation
+ // if KQML functor is not changed
+ if (c.getKqmlFunctor().equals(Message.kqmlReceivedFunctor)) {
+ String file = Message.kqmlDefaultPlans.substring(Message.kqmlDefaultPlans.indexOf("/"));
+ if (JasonException.class.getResource(file) != null) {
+ setASLSrc("kqmlPlans.asl");
+ parseAS(JasonException.class.getResource(file));
+ } else {
+ logger.warning("The kqmlPlans.asl was not found!");
+ }
+ }
} else {
- logger.warning("The kqmlPlans.asl was not found!");
+ // load from specified file
+ try {
+ parseAS(new File(c.getKqmlPlansFile()));
+ } catch (Exception e) {
+ logger.warning("Error reading kqml semantic plans. "+e+". from file "+c.getKqmlPlansFile());
+ }
}
+ setASLSrc(asSrc);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error creating customised Agent class!", e);
throw new JasonException("Error creating customised Agent class! - " + e);
Modified: trunk/src/jason/asSemantics/Message.java
===================================================================
--- trunk/src/jason/asSemantics/Message.java 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/src/jason/asSemantics/Message.java 2015-04-13 20:15:05 UTC (rev 1834)
@@ -48,6 +48,7 @@
public final static String msgIdSyncAskPrefix = "samid";
public final static String kqmlReceivedFunctor = "kqml_received";
+ public final static String kqmlDefaultPlans = "$jasonJar/asl/kqmlPlans.asl";
public Message() {
}
Modified: trunk/src/jason/asSemantics/TransitionSystem.java
===================================================================
--- trunk/src/jason/asSemantics/TransitionSystem.java 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/src/jason/asSemantics/TransitionSystem.java 2015-04-13 20:15:05 UTC (rev 1834)
@@ -53,6 +53,7 @@
import jason.asSyntax.VarTerm;
import jason.asSyntax.parser.ParseException;
import jason.bb.BeliefBase;
+import jason.jeditplugin.Config;
import jason.runtime.Settings;
import jason.stdlib.add_nested_source;
import jason.stdlib.desire;
@@ -229,6 +230,8 @@
// the semantic rules are referred to in comments in the functions below
+ private String kqmlReceivedFunctor = Config.get().getKqmlFunctor();
+
private void applyProcMsg() throws JasonException {
confP.step = State.SelEv;
if (conf.C.hasMsg()) {
@@ -322,7 +325,7 @@
}
if (!added) {
- Literal received = new LiteralImpl(Message.kqmlReceivedFunctor).addTerms(
+ Literal received = new LiteralImpl(kqmlReceivedFunctor).addTerms(
new Atom(sender),
new Atom(m.getIlForce()),
content,
Modified: trunk/src/jason/asSyntax/PlanLibrary.java
===================================================================
--- trunk/src/jason/asSyntax/PlanLibrary.java 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/src/jason/asSyntax/PlanLibrary.java 2015-04-13 20:15:05 UTC (rev 1834)
@@ -26,11 +26,11 @@
import jason.JasonException;
-import jason.asSemantics.Message;
import jason.asSyntax.Trigger.TEOperator;
import jason.asSyntax.Trigger.TEType;
import jason.asSyntax.parser.ParseException;
import jason.bb.BeliefBase;
+import jason.jeditplugin.Config;
import java.util.ArrayList;
import java.util.HashMap;
@@ -144,6 +144,8 @@
add(p,false);
}
+ private String kqmlReceivedFunctor = Config.get().getKqmlFunctor();
+
/**
* Adds a plan into the plan library, either before or after all other
* plans depending on the boolean parameter.
@@ -173,7 +175,7 @@
if (!p.getLabel().hasSource())
p.getLabel().addAnnot(BeliefBase.TSelf);
- if (p.getTrigger().getLiteral().getFunctor().equals(Message.kqmlReceivedFunctor)) {
+ if (p.getTrigger().getLiteral().getFunctor().equals(kqmlReceivedFunctor)) {
if (! (p.getSrcInfo() != null && "kqmlPlans.asl".equals(p.getSrcInfo().getSrcFile()))) {
hasUserKqmlReceived = true;
}
Modified: trunk/src/jason/jeditplugin/Config.java
===================================================================
--- trunk/src/jason/jeditplugin/Config.java 2015-04-06 21:50:54 UTC (rev 1833)
+++ trunk/src/jason/jeditplugin/Config.java 2015-04-13 20:15:05 UTC (rev 1834)
@@ -23,6 +23,7 @@
package jason.jeditplugin;
+import jason.asSemantics.Message;
import jason.asSemantics.TransitionSystem;
import jason.infra.centralised.CentralisedFactory;
import jason.infra.jade.JadeFactory;
@@ -88,6 +89,9 @@
public static final String NB_TH_SCH = "numberOfThreadsForScheduler";
+ public static final String KQML_RECEIVED_FUNCTOR = "kqmlReceivedFunctor";
+ public static final String KQML_PLANS_FILE = "kqmlPlansFile";
+
private static Config singleton = null;
protected static String configFactory = null;
@@ -134,7 +138,7 @@
public String getFileConfComment() {
return "Jason user configuration";
}
-
+
/** Returns true if the file is loaded correctly */
public boolean load() {
try {
@@ -214,7 +218,7 @@
public String getAntLib() {
return getProperty(ANT_LIB);
}
-
+
public void setJavaHome(String jh) {
if (jh != null) {
jh = new File(jh).getAbsolutePath();
@@ -238,6 +242,13 @@
public String getShellCommand() {
return getProperty(SHELL_CMD);
}
+
+ public String getKqmlFunctor() {
+ return getProperty(KQML_RECEIVED_FUNCTOR, Message.kqmlReceivedFunctor);
+ }
+ public String getKqmlPlansFile() {
+ return getProperty(KQML_PLANS_FILE, Message.kqmlDefaultPlans);
+ }
/** Set most important parameters with default values */
public void fix() {
@@ -347,6 +358,14 @@
if (getProperty(SHORT_UNNAMED_VARS) == null) {
put(SHORT_UNNAMED_VARS,"true");
}
+
+ if (getProperty(KQML_RECEIVED_FUNCTOR) == null) {
+ put(KQML_RECEIVED_FUNCTOR, Message.kqmlReceivedFunctor);
+ }
+
+ if (getProperty(KQML_PLANS_FILE) == null) {
+ put(KQML_PLANS_FILE, Message.kqmlDefaultPlans);
+ }
// Default infrastructures
put("infrastructure.Centralised", CentralisedFactory.class.getName());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|