You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
(35) |
Apr
(96) |
May
(39) |
Jun
(25) |
Jul
(7) |
Aug
(7) |
Sep
(44) |
Oct
(17) |
Nov
(14) |
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(5) |
Feb
(28) |
Mar
(26) |
Apr
(14) |
May
(3) |
Jun
(3) |
Jul
(13) |
Aug
(41) |
Sep
(12) |
Oct
|
Nov
(2) |
Dec
(17) |
2010 |
Jan
(9) |
Feb
(5) |
Mar
(11) |
Apr
(3) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(8) |
Sep
(2) |
Oct
(11) |
Nov
(3) |
Dec
(1) |
2011 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(4) |
May
(4) |
Jun
(5) |
Jul
(3) |
Aug
(2) |
Sep
(7) |
Oct
(4) |
Nov
(4) |
Dec
(2) |
2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
(11) |
May
(8) |
Jun
(2) |
Jul
(7) |
Aug
(6) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(3) |
2013 |
Jan
|
Feb
(1) |
Mar
(7) |
Apr
(3) |
May
(1) |
Jun
(4) |
Jul
(8) |
Aug
(4) |
Sep
(4) |
Oct
(6) |
Nov
(8) |
Dec
(6) |
2014 |
Jan
|
Feb
|
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(10) |
Jul
|
Aug
(7) |
Sep
(15) |
Oct
(4) |
Nov
(1) |
Dec
(1) |
2015 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
(4) |
May
(6) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(5) |
Nov
(6) |
Dec
(12) |
2016 |
Jan
(1) |
Feb
(4) |
Mar
(7) |
Apr
(30) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jom...@us...> - 2014-06-10 15:00:36
|
Revision: 1790 http://sourceforge.net/p/jason/svn/1790 Author: jomifred Date: 2014-06-10 15:00:32 +0000 (Tue, 10 Jun 2014) Log Message: ----------- fix a bug related to .puts reported by B. Smilga. in jason list Modified Paths: -------------- trunk/doc/faq/faq.tex trunk/release-notes.txt trunk/src/jason/asSyntax/InternalActionLiteral.java trunk/src/jason/asSyntax/Structure.java trunk/src/jason/stdlib/puts.java Modified: trunk/doc/faq/faq.tex =================================================================== --- trunk/doc/faq/faq.tex 2014-06-07 14:10:43 UTC (rev 1789) +++ trunk/doc/faq/faq.tex 2014-06-10 15:00:32 UTC (rev 1790) @@ -573,10 +573,14 @@ % \htlink{Log4J}{http://logging.apache.org/log4j/} to output messages into the console (the default console is called MASConsole). To change the log level or device, select the menu -``Plugins -> Jason -> Edit Log properties''. The default configuration -file has comments that helps you customise your log. For instance, -to output messages both into an XML file and in the console, you only -need to set the log handler as in the following line: +``Plugins -> Jason -> Edit Log properties'' in the jEdit plugin. If +you are not using jEdit, you can copy de default configuration file +from +\texttt{..../JASON_HOME_DIRECTORY/src/templates/logging.properties} to +your application directory. The default configuration file has +comments that helps you customise your log. For instance, to output +messages both into an XML file and in the console, you only need to +set the log handler as in the following line: \begin{verbatim} handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler \end{verbatim} Modified: trunk/release-notes.txt =================================================================== --- trunk/release-notes.txt 2014-06-07 14:10:43 UTC (rev 1789) +++ trunk/release-notes.txt 2014-06-10 15:00:32 UTC (rev 1790) @@ -1,4 +1,15 @@ --------------------------- +version 1.4.1 + +revision X on SVN +--------------------------- + +New features + +- web view of agent's mind (url usually is http://localhost:3272) + + +--------------------------- version 1.4.0 revision 1759 on SVN Modified: trunk/src/jason/asSyntax/InternalActionLiteral.java =================================================================== --- trunk/src/jason/asSyntax/InternalActionLiteral.java 2014-06-07 14:10:43 UTC (rev 1789) +++ trunk/src/jason/asSyntax/InternalActionLiteral.java 2014-06-10 15:00:32 UTC (rev 1790) @@ -26,6 +26,7 @@ import jason.asSemantics.Agent; import jason.asSemantics.InternalAction; import jason.asSemantics.Unifier; +import jason.stdlib.puts; import java.util.ConcurrentModificationException; import java.util.Iterator; @@ -81,6 +82,16 @@ public boolean isAtom() { return false; } + + @Override + public Literal makeVarsAnnon(Unifier un) { + Literal t = super.makeVarsAnnon(un); + if (t.getFunctor().equals(".puts")) { // vars inside strings like in .puts("bla #{X}") should be also replace + // TODO: should it work for any string? if so, proceed this replacement inside StringTermImpl + ((puts)puts.create()).makeVarsAnnon(t,un); + } + return t; + } @SuppressWarnings("unchecked") public Iterator<Unifier> logicalConsequence(Agent ag, Unifier un) { Modified: trunk/src/jason/asSyntax/Structure.java =================================================================== --- trunk/src/jason/asSyntax/Structure.java 2014-06-07 14:10:43 UTC (rev 1789) +++ trunk/src/jason/asSyntax/Structure.java 2014-06-10 15:00:32 UTC (rev 1790) @@ -346,7 +346,7 @@ private final static boolean useShortUnnamedVars = Config.get().getBoolean(Config.SHORT_UNNAMED_VARS); - protected VarTerm varToReplace(Term t, Unifier un) { + public VarTerm varToReplace(Term t, Unifier un) { VarTerm vt = (VarTerm)t; VarTerm deref = un.deref(vt); //if (deref.isUnnamedVar()) Modified: trunk/src/jason/stdlib/puts.java =================================================================== --- trunk/src/jason/stdlib/puts.java 2014-06-07 14:10:43 UTC (rev 1789) +++ trunk/src/jason/stdlib/puts.java 2014-06-10 15:00:32 UTC (rev 1790) @@ -1,13 +1,17 @@ package jason.stdlib; +import jason.JasonException; import jason.asSemantics.DefaultInternalAction; import jason.asSemantics.InternalAction; import jason.asSemantics.TransitionSystem; import jason.asSemantics.Unifier; import jason.asSyntax.ASSyntax; +import jason.asSyntax.Literal; import jason.asSyntax.StringTerm; import jason.asSyntax.StringTermImpl; +import jason.asSyntax.Structure; import jason.asSyntax.Term; +import jason.asSyntax.VarTerm; import jason.asSyntax.parser.ParseException; import java.util.regex.Matcher; @@ -73,15 +77,21 @@ } //Pattern regex = Pattern.compile("#\\{\\p{Upper}\\p{Alnum}*\\}"); - Pattern regex = Pattern.compile("#\\{\\p{Alnum}+\\}"); + Pattern regex = Pattern.compile("#\\{[\\p{Alnum}_]+\\}"); + + @Override public int getMinArgs() { return 1; } + @Override public int getMaxArgs() { return 2; } + @Override protected void checkArguments(Term[] args) throws JasonException { + super.checkArguments(args); // check number of arguments + if (!args[0].isString()) + throw JasonException.createWrongArgument(this,"first argument must be a string"); + } + @Override - public Object execute(TransitionSystem ts, Unifier un, Term[] args) - throws Exception { - if (!args[0].isString()) { - return false; - } - + public Object execute(TransitionSystem ts, Unifier un, Term[] args) throws Exception { + checkArguments(args); + StringBuffer sb = new StringBuffer(); for (Term term : args) { if (!term.isString()) { @@ -123,4 +133,31 @@ return true; } } + + public void makeVarsAnnon(Literal l, Unifier un) { + try { + for (int i=0; i<l.getArity(); i++) { + Term t = l.getTerm(i); + if (t.isString()) { + StringTerm st = (StringTerm)t; + Matcher matcher = regex.matcher(st.getString()); + StringBuffer sb = new StringBuffer(); + + while (matcher.find()) { + String sVar = matcher.group(); + sVar = sVar.substring(2, sVar.length() - 1); + Term v = ASSyntax.parseTerm(sVar); + if (v.isVar()) { + VarTerm to = ((Structure)l).varToReplace(v, un); + matcher.appendReplacement(sb, "#{"+to.toString()+"}"); + } + } + matcher.appendTail(sb); + l.setTerm(i, new StringTermImpl(sb.toString())); + } + } + } catch (ParseException pe) { + pe.printStackTrace(); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-07 14:10:48
|
Revision: 1789 http://sourceforge.net/p/jason/svn/1789 Author: jomifred Date: 2014-06-07 14:10:43 +0000 (Sat, 07 Jun 2014) Log Message: ----------- minor fixes in mind inspector Modified Paths: -------------- trunk/src/jason/architecture/MindInspectorWeb.java Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2014-06-06 19:20:11 UTC (rev 1788) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-06-07 14:10:43 UTC (rev 1789) @@ -50,6 +50,17 @@ return singleton; } + public static boolean isRunning() { + return singleton != null; + } + + public static String getURL() { + if (singleton != null) + return singleton.httpServerURL; + else + return null; + } + private MindInspectorWeb() { } @@ -112,6 +123,7 @@ private String getAgNameFromPath(String path) { int nameStart = path.indexOf("agent-mind")+11; + if (nameStart < 0) return null; int nameEnd = path.indexOf("/",nameStart+1); if (nameEnd >= 0) return path.substring(nameStart,nameEnd).trim(); @@ -172,8 +184,10 @@ /** add the agent in the list of available agent for mind inspection */ public synchronized void registerAg(Agent ag) { String agName = ag.getTS().getUserAgArch().getAgName(); - registeredAgents.put(agName, ag); - histories.put(agName, new ArrayList<Document>()); // just for the agent name to appear in the list of agents + if (!agName.equals("no-named")) { + registeredAgents.put(agName, ag); + histories.put(agName, new ArrayList<Document>()); // just for the agent name to appear in the list of agents + } } public synchronized void addAgState(Agent ag, Document mind, boolean hasHistory) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-06 19:20:22
|
Revision: 1788 http://sourceforge.net/p/jason/svn/1788 Author: jomifred Date: 2014-06-06 19:20:11 +0000 (Fri, 06 Jun 2014) Log Message: ----------- improve web mind inspector Modified Paths: -------------- trunk/examples/auction/auction.mas2j trunk/src/jason/architecture/MindInspectorAgArch.java trunk/src/jason/architecture/MindInspectorWeb.java trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/RunCentralisedMAS.java trunk/src/jason/infra/jade/JadeMASLauncherAnt.java trunk/src/jason/jeditplugin/Config.java Modified: trunk/examples/auction/auction.mas2j =================================================================== --- trunk/examples/auction/auction.mas2j 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/examples/auction/auction.mas2j 2014-06-06 19:20:11 UTC (rev 1788) @@ -6,7 +6,6 @@ agents: ag1; ag2; - ag3 [mindinspector="web(cycle,html,history)"]; // two agents with web view of their minds - auctioneer [mindinspector="web(cycle,html,history)"] - agentArchClass AuctioneerGUI; + ag3 [mindinspector="gui(cycle,html,history)"]; // this agent has a GUI mind inspector + auctioneer agentArchClass AuctioneerGUI; } Modified: trunk/src/jason/architecture/MindInspectorAgArch.java =================================================================== --- trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -118,7 +118,7 @@ * E.g. agents bob x.asl [mindinspector="gui(cycle,html)"]; * * General syntax of the parameter: - * [gui|file] ( [ cycle|number ] , [xml,html] [, history | directory] ) + * [gui|file|web] ( [ cycle|number ] , [xml,html] [, history | directory] ) */ protected void setupMindInspector(String configuration) { Structure sConf = null; Modified: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -37,12 +37,15 @@ //private Map<String,Boolean> agHasHistory = new HashMap<String, Boolean>(); private Map<String,List<Document>> histories = new TreeMap<String,List<Document>>(); private Map<String,Integer> lastStepSeenByUser = new HashMap<String, Integer>(); + private Map<String,Agent> registeredAgents = new HashMap<String, Agent>(); public static synchronized MindInspectorWeb get() { if (singleton == null) { singleton = new MindInspectorWeb(); singleton.startHttpServer(); singleton.registerRootBrowserView(); + singleton.registerAgentsBrowserView(); + singleton.registerAgView("no_ag"); } return singleton; } @@ -83,15 +86,81 @@ OutputStream responseBody = exchange.getResponseBody(); if (requestMethod.equalsIgnoreCase("GET")) { - responseBody.write(("<html><head><title>Jason Mind Inspector -- Web View</title><meta http-equiv=\"refresh\" content=\""+refreshInterval+"\" ></head><body>").getBytes()); - responseBody.write(("<h2>Agents</h2><ul>").getBytes()); + String path = exchange.getRequestURI().getPath(); + StringWriter so = new StringWriter(); + + if (path.length() < 2) { // it is the root + so.append("<html><head><title>Jason Mind Inspector -- Web View</title></head><body>"); + so.append("<iframe width=\"20%\" height=\"100%\" align=left src=\"/agents\" border=5 frameborder=0 ></iframe>"); + so.append("<iframe width=\"78%\" height=\"100%\" align=left src=\"/agent-mind/no_ag\" name=\"am\" border=5 frameborder=0></iframe>"); + so.append("</body></html>"); + } else if (path.indexOf("agent-mind") >= 0) { + if (tryToIncludeMindInspectorForAg(path)) + so.append("<meta http-equiv=\"refresh\" content=0>"); + else + so.append("unkown agent!"); + } + responseBody.write(so.toString().getBytes()); + } + responseBody.close(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private String getAgNameFromPath(String path) { + int nameStart = path.indexOf("agent-mind")+11; + int nameEnd = path.indexOf("/",nameStart+1); + if (nameEnd >= 0) + return path.substring(nameStart,nameEnd).trim(); + else + return path.substring(nameStart).trim(); + } + + private boolean tryToIncludeMindInspectorForAg(String path) { + try { + Agent ag = registeredAgents.get(getAgNameFromPath(path)); + if (ag != null) { + AgArch arch = ag.getTS().getUserAgArch(); + if (arch != null) { + // should add a new conf for mindinspector, otherwise will start a new gui for the agent + arch.getTS().getSettings().addOption("mindinspector","web(cycle,html,history)"); + MindInspectorAgArch miArch = new MindInspectorAgArch(); + arch.insertAgArch(miArch); + miArch.init(); + miArch.addAgState(); + return true; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + private void registerAgentsBrowserView() { + if (httpServer == null) + return; + try { + httpServer.createContext("/agents", new HttpHandler() { + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + Headers responseHeaders = exchange.getResponseHeaders(); + responseHeaders.set("Content-Type", "text/html"); + exchange.sendResponseHeaders(200, 0); + OutputStream responseBody = exchange.getResponseBody(); + + if (requestMethod.equalsIgnoreCase("GET")) { + responseBody.write(("<html><head><title>Jason (list of agents)</title><meta http-equiv=\"refresh\" content=\""+refreshInterval+"\" ></head><body>").getBytes()); + responseBody.write(("<font size=\"+2\"><p style='color: red; font-family: arial;'>Agents</p></font>").getBytes()); for (String a: histories.keySet()) { - responseBody.write( ("<li><a href=\"/agent-mind/"+a+"/latest\">"+a+"</a>").getBytes()); - //responseBody.write( (" <a href=\"/agent-code/"+a+"\">(code)</a></li>").getBytes()); - responseBody.write( ("</li>").getBytes()); + responseBody.write( ("- <a href=\"/agent-mind/"+a+"/latest\" target=\"am\" style=\"font-family: arial; text-decoration: none\">"+a+"</a><br/>").getBytes()); } - responseBody.write("</ul><hr/><a href=\"http://jason.sf.net\">Jason</a></body></html>".getBytes()); } + responseBody.write("<hr/>by <a href=\"http://jason.sf.net\" target=\"_blank\">Jason</a>".getBytes()); + responseBody.write("</body></html>".getBytes()); responseBody.close(); } }); @@ -100,15 +169,22 @@ } } + /** add the agent in the list of available agent for mind inspection */ + public synchronized void registerAg(Agent ag) { + String agName = ag.getTS().getUserAgArch().getAgName(); + registeredAgents.put(agName, ag); + histories.put(agName, new ArrayList<Document>()); // just for the agent name to appear in the list of agents + } + public synchronized void addAgState(Agent ag, Document mind, boolean hasHistory) { String agName = ag.getTS().getUserAgArch().getAgName(); List<Document> h = histories.get(agName); if (h == null) { h = new ArrayList<Document>(); - registerAgView(agName); - //registerAgCodeBrowserView(agName, "not implemented"); histories.put(agName, h); } + if (h.isEmpty()) + registerAgView(agName); // the first time a state is added for the agent, register in the browser if (hasHistory || h.isEmpty()) h.add(mind); else @@ -132,63 +208,73 @@ try { StringWriter so = new StringWriter(); so.append("<html><head><title>"+agName+"</title>"); - List<Document> h = histories.get(agName); - if (h != null) { - Document agState; - int i = -1; - exchange.getRemoteAddress(); - - String path = exchange.getRequestURI().getPath(); - String query = exchange.getRequestURI().getRawQuery(); // what follows ? - String remote = exchange.getRemoteAddress().toString(); - - if (path.endsWith("hide")) { - show.put(query,false); - Integer ii = lastStepSeenByUser.get(remote); - if (ii != null) - i = ii; - } else if (path.endsWith("show")) { - show.put(query,true); - Integer ii = lastStepSeenByUser.get(remote); - if (ii != null) - i = ii; - } else if (path.endsWith("clear")) { - agState = h.get(h.size()-1); - h.clear(); - h.add(agState); - } else { - // see if ends with a number + + // test if the url is for this agent + String path = exchange.getRequestURI().getPath(); + if (!getAgNameFromPath(path).equals(agName)) { + if (tryToIncludeMindInspectorForAg(path)) + so.append("<meta http-equiv=\"refresh\" content=0>"); + else + so.append("unkown agent!"); + } else { + + List<Document> h = histories.get(agName); + if (h != null && h.size() > 0) { + Document agState; + int i = -1; + exchange.getRemoteAddress(); + + String query = exchange.getRequestURI().getRawQuery(); // what follows ? + String remote = exchange.getRemoteAddress().toString(); + + if (path.endsWith("hide")) { + show.put(query,false); + Integer ii = lastStepSeenByUser.get(remote); + if (ii != null) + i = ii; + } else if (path.endsWith("show")) { + show.put(query,true); + Integer ii = lastStepSeenByUser.get(remote); + if (ii != null) + i = ii; + } else if (path.endsWith("clear")) { + agState = h.get(h.size()-1); + h.clear(); + h.add(agState); + } else { + // see if ends with a number + try { + int pos = path.lastIndexOf("/"); + String n = path.substring(pos+1).trim(); + i = new Integer(n); + } catch (Exception e) {} + } + if (i == -1) { + so.append("<meta http-equiv=\"refresh\" content=\""+refreshInterval+"\">"); + agState = h.get(h.size()-1); + } else { + agState = h.get(i-1); + } try { - int pos = path.lastIndexOf("/"); - String n = path.substring(pos+1).trim(); - i = new Integer(n); - } catch (Exception e) {} - } - if (i == -1) { - so.append("<meta http-equiv=\"refresh\" content=\""+refreshInterval+"\">"); - agState = h.get(h.size()-1); - } else { - agState = h.get(i-1); - } - try { - lastStepSeenByUser.put(remote, i); - } catch (Exception e) { - e.printStackTrace(); - } - so.append("</head><body>"); - if (h.size() > 1) { - so.append("history: "); - so.append("<a href=/agent-mind/"+agName+"/latest>latest state</a> "); - for (i=h.size()-1; i>0; i--) { - so.append("<a href=\"/agent-mind/"+agName+"/"+i+"\" style=\"text-decoration: none\">"+i+"</a> "); + lastStepSeenByUser.put(remote, i); + } catch (Exception e) { + e.printStackTrace(); } - so.append("<a href=\"/agent-mind/"+agName+"/clear\">clear history</a> "); - so.append("<hr/>"); + so.append("</head><body>"); + if (h.size() > 1) { + //so.append("history: "); + so.append("<a href=/agent-mind/"+agName+"/latest>latest state</a> "); + for (i=h.size()-1; i>0; i--) { + so.append("<a href=\"/agent-mind/"+agName+"/"+i+"\" style=\"text-decoration: none\">"+i+"</a> "); + } + so.append("<a href=\"/agent-mind/"+agName+"/clear\">clear history</a> "); + so.append("<hr/>"); + } + so.append(getAgStateAsString(agState, false)); + //so.append("<hr/><a href=\"/\"> list of agents</a> "); + } else { + so.append("select an agent"); } - so.append(getAgStateAsString(agState, false)); - so.append("<hr/><a href=\"/\"> list of agents</a> "); - } else { - so.append("no register for this agent!"); } responseBody.write(so.toString().getBytes()); Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/asSemantics/Agent.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -26,6 +26,7 @@ import jason.JasonException; import jason.RevisionFailedException; import jason.architecture.AgArch; +import jason.architecture.MindInspectorWeb; import jason.asSyntax.ASSyntax; import jason.asSyntax.ArithFunctionTerm; import jason.asSyntax.InternalActionLiteral; @@ -46,6 +47,7 @@ import jason.bb.DefaultBeliefBase; import jason.functions.Count; import jason.functions.RuleToFunction; +import jason.jeditplugin.Config; import jason.mas2j.ClassParameters; import jason.profiling.QueryProfiling; import jason.runtime.Settings; @@ -155,6 +157,8 @@ //if (ts.getSettings().hasQueryCache()) qCache = new QueryCache(this); if (ts.getSettings().hasQueryProfiling()) qProfiling = new QueryProfiling(this); if (ts.getSettings().hasQueryCache()) qCache = new QueryCacheSimple(this, qProfiling); + + if (! "false".equals(Config.get().getProperty(Config.START_WEB_MI))) MindInspectorWeb.get().registerAg(this); } Modified: trunk/src/jason/infra/centralised/RunCentralisedMAS.java =================================================================== --- trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/infra/centralised/RunCentralisedMAS.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -206,7 +206,7 @@ /** start agents, .... */ public void start() { startAgs(); - startSyncMode(); + startSyncMode(); } public static boolean isDebug() { Modified: trunk/src/jason/infra/jade/JadeMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -167,7 +167,7 @@ } args = Config.get().getJadeArgs(); if (mainHostPort > 0) - args += "-port "+mainHostPort; + args += " -port "+mainHostPort; if (Config.get().getBoolean(Config.JADE_RMA)) args += " -gui "; } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-06-03 20:05:43 UTC (rev 1787) +++ trunk/src/jason/jeditplugin/Config.java 2014-06-06 19:20:11 UTC (rev 1788) @@ -83,6 +83,7 @@ public static final String jacamoHomeProp = "JaCaMoHome"; public static final String SHORT_UNNAMED_VARS = "shortUnnamedVars"; + public static final String START_WEB_MI = "startWebMindInspector"; private static Config singleton = null; @@ -313,6 +314,10 @@ if (getProperty(SHOW_ANNOTS) == null) { put(SHOW_ANNOTS, "true"); } + + if (getProperty(START_WEB_MI) == null) { + put(START_WEB_MI, "true"); + } // 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. |
From: <jom...@us...> - 2014-06-03 20:05:48
|
Revision: 1787 http://sourceforge.net/p/jason/svn/1787 Author: jomifred Date: 2014-06-03 20:05:43 +0000 (Tue, 03 Jun 2014) Log Message: ----------- add port also in main container Modified Paths: -------------- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java Modified: trunk/src/jason/infra/jade/JadeMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-03 19:57:20 UTC (rev 1786) +++ trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-03 20:05:43 UTC (rev 1787) @@ -166,6 +166,8 @@ sep = ";"; } args = Config.get().getJadeArgs(); + if (mainHostPort > 0) + args += "-port "+mainHostPort; if (Config.get().getBoolean(Config.JADE_RMA)) args += " -gui "; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-03 19:57:27
|
Revision: 1786 http://sourceforge.net/p/jason/svn/1786 Author: jomifred Date: 2014-06-03 19:57:20 +0000 (Tue, 03 Jun 2014) Log Message: ----------- consider port in the jade main host Modified Paths: -------------- trunk/doc/faq/faq.tex trunk/src/jason/infra/jade/JadeMASLauncherAnt.java Modified: trunk/doc/faq/faq.tex =================================================================== --- trunk/doc/faq/faq.tex 2014-06-03 18:50:24 UTC (rev 1785) +++ trunk/doc/faq/faq.tex 2014-06-03 19:57:20 UTC (rev 1786) @@ -16,7 +16,7 @@ \html{\begin{rawhtml}<h0><b><i>Jason</i></b> FAQ - <br><font size="-1">(for version > 1.3.7)</font></h0> + <br><font size="-1">(for version > 1.4.1)</font></h0> \end{rawhtml}} \latex{\begin{center}{\Huge\jason FAQ}\end{center}} Modified: trunk/src/jason/infra/jade/JadeMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-03 18:50:24 UTC (rev 1785) +++ trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2014-06-03 19:57:20 UTC (rev 1786) @@ -109,7 +109,18 @@ e.printStackTrace(); } } + int mainHostPort = -1; + int pos = mainHost.indexOf(":"); + if (pos > 0) { + try { + mainHostPort = new Integer(mainHost.substring(pos+1)); + } catch (Exception e) { + e.printStackTrace(); + } + mainHost = mainHost.substring(0,pos); + } + // identify type of allocation (by class of info in .mas2h) ContainerAllocation allocator = null; String allocationClass = project.getInfrastructure().getParameter("container_allocation"); @@ -144,6 +155,8 @@ for (String container: containers) { String sep = " "; String args = "-container -host "+mainHost+" -container-name "+container+" "; + if (mainHostPort > 0) + args += "-port "+mainHostPort; StringBuilder agents = new StringBuilder(); if (container.equals("Main-Container")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-03 18:50:32
|
Revision: 1785 http://sourceforge.net/p/jason/svn/1785 Author: jomifred Date: 2014-06-03 18:50:24 +0000 (Tue, 03 Jun 2014) Log Message: ----------- include option for mindinspector to be seen in a browser Modified Paths: -------------- trunk/doc/faq/faq.tex trunk/examples/auction/auction.mas2j trunk/src/jason/architecture/MindInspectorAgArch.java trunk/src/jason/control/ExecutionControlGUI.java trunk/src/xml/agInspection.xsl Added Paths: ----------- trunk/src/jason/architecture/MindInspectorWeb.java Modified: trunk/doc/faq/faq.tex =================================================================== --- trunk/doc/faq/faq.tex 2014-06-02 21:28:22 UTC (rev 1784) +++ trunk/doc/faq/faq.tex 2014-06-03 18:50:24 UTC (rev 1785) @@ -613,6 +613,13 @@ bob [mindinspector="gui(2000,html,history)"]; \end{verbatim} + +You can also see the history of minds in a browser with the following configuration: +\begin{verbatim} + bob [mindinspector="web(cycle,html,history)"]; +\end{verbatim} +The URL is typically http://<your host up>:3272/. + To store the history of minds in files, use the following configuration: \begin{verbatim} bob [mindinspector="file(cycle,xml,log)"]; @@ -622,6 +629,7 @@ files with suitable style sheets to be viewed in browsers. + % --------------------------------------------------------------------- \section{\jason Infrastructures} Modified: trunk/examples/auction/auction.mas2j =================================================================== --- trunk/examples/auction/auction.mas2j 2014-06-02 21:28:22 UTC (rev 1784) +++ trunk/examples/auction/auction.mas2j 2014-06-03 18:50:24 UTC (rev 1785) @@ -6,7 +6,7 @@ agents: ag1; ag2; - ag3; - auctioneer //[mindinspector="gui(cycle,html,history)"] + ag3 [mindinspector="web(cycle,html,history)"]; // two agents with web view of their minds + auctioneer [mindinspector="web(cycle,html,history)"] agentArchClass AuctioneerGUI; } Modified: trunk/src/jason/architecture/MindInspectorAgArch.java =================================================================== --- trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-02 21:28:22 UTC (rev 1784) +++ trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-03 18:50:24 UTC (rev 1785) @@ -84,8 +84,10 @@ // what is currently shown Document agState = null; - - + + MindInspectorWeb webServer = null; + boolean hasHistory = false; + @Override public void init() { setupMindInspector(getTS().getSettings().getUserParameter("mindinspector")); @@ -123,7 +125,7 @@ try { sConf = ASSyntax.parseStructure(configuration); } catch (Exception e) { - getTS().getLogger().warning("The mindinspector argument does not parse as a predicate! "+configuration+" -- error: "+e); + getTS().getLogger().warning("The mindinspector argument does not parse as a predicate! "+configuration+" -- (see Jason FAQ) -- error: "+e); return; } @@ -154,6 +156,8 @@ createGUIMindInspector(sConf); } else if (sConf.getFunctor().equals("file")) { createFileMindInspector(sConf); + } else if (sConf.getFunctor().equals("web")) { + createWebMindInspector(sConf); } } @@ -251,8 +255,6 @@ } } - - private void setupSlider() { int size = mindInspectorHistory.size()-1; if (size < 0) @@ -292,6 +294,12 @@ new File(mindInspectorDirectory).mkdirs(); } + private void createWebMindInspector(Structure sConf) { + webServer = MindInspectorWeb.get(); + hasHistory = sConf.getArity() == 3 && sConf.getTerm(2).toString().equals("history"); + mindInspectorTransformer = new asl2html("/xml/agInspection.xsl"); + } + private String lastHistoryText = ""; private int fileCounter = 0; @@ -317,6 +325,8 @@ FileWriter outmind = new FileWriter(new File(mindInspectorDirectory+"/"+filename)); outmind.write(sMind); outmind.close(); + } else if (webServer != null) { // output on web + webServer.addAgState(getTS().getAg(), state, hasHistory); } } catch (Exception e) { e.printStackTrace(); @@ -350,7 +360,9 @@ mindInspectorTransformer.setParameter("show-"+p, show.get(p)+""); return mindInspectorTransformer.transform(ag); // transform to HTML } catch (Exception e) { - mindInspectorPanel.setText("Error in XML transformation!" + e); + if (mindInspectorPanel != null) { + mindInspectorPanel.setText("Error in XML transformation!" + e); + } e.printStackTrace(); return "Error XML transformation (MindInspector)"; } Added: trunk/src/jason/architecture/MindInspectorWeb.java =================================================================== --- trunk/src/jason/architecture/MindInspectorWeb.java (rev 0) +++ trunk/src/jason/architecture/MindInspectorWeb.java 2014-06-03 18:50:24 UTC (rev 1785) @@ -0,0 +1,269 @@ +package jason.architecture; + +import jason.asSemantics.Agent; +import jason.jeditplugin.Config; +import jason.util.asl2html; +import jason.util.asl2xml; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.StringWriter; +import java.net.BindException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.Executors; + +import org.w3c.dom.Document; + +import com.sun.net.httpserver.Headers; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; + +public class MindInspectorWeb { + + private static MindInspectorWeb singleton = null; + + private HttpServer httpServer = null; + private String httpServerURL = "http://localhost:3272"; + private int httpServerPort = 3272; + private int refreshInterval = 5; + + //private Map<String,Boolean> agHasHistory = new HashMap<String, Boolean>(); + private Map<String,List<Document>> histories = new TreeMap<String,List<Document>>(); + private Map<String,Integer> lastStepSeenByUser = new HashMap<String, Integer>(); + + public static synchronized MindInspectorWeb get() { + if (singleton == null) { + singleton = new MindInspectorWeb(); + singleton.startHttpServer(); + singleton.registerRootBrowserView(); + } + return singleton; + } + + private MindInspectorWeb() { + } + + private synchronized String startHttpServer() { + if (httpServer == null) { + try { + httpServer = HttpServer.create(new InetSocketAddress(httpServerPort), 0); + httpServer.setExecutor(Executors.newCachedThreadPool()); + + httpServer.start(); + httpServerURL = "http://"+InetAddress.getLocalHost().getHostAddress()+":"+httpServerPort; + System.out.println("Jason Http Server running on "+httpServerURL); + } catch (BindException e) { + httpServerPort++; + return startHttpServer(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + return httpServerURL; + } + + private void registerRootBrowserView() { + if (httpServer == null) + return; + try { + httpServer.createContext("/", new HttpHandler() { + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + Headers responseHeaders = exchange.getResponseHeaders(); + responseHeaders.set("Content-Type", "text/html"); + exchange.sendResponseHeaders(200, 0); + OutputStream responseBody = exchange.getResponseBody(); + + if (requestMethod.equalsIgnoreCase("GET")) { + responseBody.write(("<html><head><title>Jason Mind Inspector -- Web View</title><meta http-equiv=\"refresh\" content=\""+refreshInterval+"\" ></head><body>").getBytes()); + responseBody.write(("<h2>Agents</h2><ul>").getBytes()); + for (String a: histories.keySet()) { + responseBody.write( ("<li><a href=\"/agent-mind/"+a+"/latest\">"+a+"</a>").getBytes()); + //responseBody.write( (" <a href=\"/agent-code/"+a+"\">(code)</a></li>").getBytes()); + responseBody.write( ("</li>").getBytes()); + } + responseBody.write("</ul><hr/><a href=\"http://jason.sf.net\">Jason</a></body></html>".getBytes()); + } + responseBody.close(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public synchronized void addAgState(Agent ag, Document mind, boolean hasHistory) { + String agName = ag.getTS().getUserAgArch().getAgName(); + List<Document> h = histories.get(agName); + if (h == null) { + h = new ArrayList<Document>(); + registerAgView(agName); + //registerAgCodeBrowserView(agName, "not implemented"); + histories.put(agName, h); + } + if (hasHistory || h.isEmpty()) + h.add(mind); + else + h.set(0, mind); + } + + String registerAgView(final String agName) { + if (httpServer == null) + return null; + try { + String url = "/agent-mind/"+agName; + httpServer.createContext(url, new HttpHandler() { + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + Headers responseHeaders = exchange.getResponseHeaders(); + exchange.sendResponseHeaders(200, 0); + OutputStream responseBody = exchange.getResponseBody(); + responseHeaders.set("Content-Type", "text/html"); + + if (requestMethod.equalsIgnoreCase("GET")) { + try { + StringWriter so = new StringWriter(); + so.append("<html><head><title>"+agName+"</title>"); + List<Document> h = histories.get(agName); + if (h != null) { + Document agState; + int i = -1; + exchange.getRemoteAddress(); + + String path = exchange.getRequestURI().getPath(); + String query = exchange.getRequestURI().getRawQuery(); // what follows ? + String remote = exchange.getRemoteAddress().toString(); + + if (path.endsWith("hide")) { + show.put(query,false); + Integer ii = lastStepSeenByUser.get(remote); + if (ii != null) + i = ii; + } else if (path.endsWith("show")) { + show.put(query,true); + Integer ii = lastStepSeenByUser.get(remote); + if (ii != null) + i = ii; + } else if (path.endsWith("clear")) { + agState = h.get(h.size()-1); + h.clear(); + h.add(agState); + } else { + // see if ends with a number + try { + int pos = path.lastIndexOf("/"); + String n = path.substring(pos+1).trim(); + i = new Integer(n); + } catch (Exception e) {} + } + if (i == -1) { + so.append("<meta http-equiv=\"refresh\" content=\""+refreshInterval+"\">"); + agState = h.get(h.size()-1); + } else { + agState = h.get(i-1); + } + try { + lastStepSeenByUser.put(remote, i); + } catch (Exception e) { + e.printStackTrace(); + } + so.append("</head><body>"); + if (h.size() > 1) { + so.append("history: "); + so.append("<a href=/agent-mind/"+agName+"/latest>latest state</a> "); + for (i=h.size()-1; i>0; i--) { + so.append("<a href=\"/agent-mind/"+agName+"/"+i+"\" style=\"text-decoration: none\">"+i+"</a> "); + } + so.append("<a href=\"/agent-mind/"+agName+"/clear\">clear history</a> "); + so.append("<hr/>"); + } + so.append(getAgStateAsString(agState, false)); + so.append("<hr/><a href=\"/\"> list of agents</a> "); + } else { + so.append("no register for this agent!"); + } + responseBody.write(so.toString().getBytes()); + + //responseBody.write(("<br/><a href=/agent-code/"+agName+">code</a>").getBytes()); + responseBody.write("</body></html>".getBytes()); + } catch (Exception e) { + e.printStackTrace(); + } + } + responseBody.close(); + } + }); + return httpServerURL+url; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /* + String registerAgCodeBrowserView(String agId, final String agCode) { + if (httpServer == null) + return null; + try { + String url="/agent-code/"+agId; + httpServer.createContext(url, new HttpHandler() { + public void handle(HttpExchange exchange) throws IOException { + String requestMethod = exchange.getRequestMethod(); + Headers responseHeaders = exchange.getResponseHeaders(); + responseHeaders.set("Content-Type", "text/html"); + exchange.sendResponseHeaders(200, 0); + OutputStream responseBody = exchange.getResponseBody(); + + if (requestMethod.equalsIgnoreCase("GET")) { + responseBody.write(agCode.getBytes()); + } + responseBody.close(); + } + }); + return httpServerURL+url; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + */ + + protected asl2xml mindInspectorTransformer = null; + Map<String,Boolean> show = new HashMap<String,Boolean>(); + + synchronized String getAgStateAsString(Document ag, boolean full) { // full means with show all + try { + if (mindInspectorTransformer == null) { + mindInspectorTransformer = new asl2html("/xml/agInspection.xsl"); + + show.put("bels", true); + show.put("annots", Config.get().getBoolean(Config.SHOW_ANNOTS)); + show.put("rules", false); + show.put("evt", true); + show.put("mb", false); + show.put("int", false); + show.put("int-details", false); + show.put("plan", false); + show.put("plan-details", false); + } + for (String p: show.keySet()) + if (full) + mindInspectorTransformer.setParameter("show-"+p, "true"); + else + mindInspectorTransformer.setParameter("show-"+p, show.get(p)+""); + return mindInspectorTransformer.transform(ag); // transform to HTML + } catch (Exception e) { + e.printStackTrace(); + return "Error XML transformation (MindInspector)"; + } + } + +} Modified: trunk/src/jason/control/ExecutionControlGUI.java =================================================================== --- trunk/src/jason/control/ExecutionControlGUI.java 2014-06-02 21:28:22 UTC (rev 1784) +++ trunk/src/jason/control/ExecutionControlGUI.java 2014-06-03 18:50:24 UTC (rev 1785) @@ -125,7 +125,7 @@ // Which item is to be shown in HTML interface Map<String,Boolean> show = new HashMap<String,Boolean>(); - public static String title = ":: Jason Mind Inspector ::"; + public static String title = "..:: Mind Inspector ::.."; void initComponents() { frame = new JFrame(title); Modified: trunk/src/xml/agInspection.xsl =================================================================== --- trunk/src/xml/agInspection.xsl 2014-06-02 21:28:22 UTC (rev 1784) +++ trunk/src/xml/agInspection.xsl 2014-06-03 18:50:24 UTC (rev 1785) @@ -287,11 +287,8 @@ <xsl:apply-templates select="@trigger"/> <xsl:if test="$show-int-details='true'"> <!-- td valign="top" style="{$td-style}" --> - <br/> - - <font size="-2"> - <pre> <- ... <xsl:apply-templates select="body"/> </pre> - </font> + <br/> + <pre> <- ... <xsl:apply-templates select="body"/> </pre> <!-- /td --> </xsl:if> </td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-02 21:28:27
|
Revision: 1784 http://sourceforge.net/p/jason/svn/1784 Author: jomifred Date: 2014-06-02 21:28:22 +0000 (Mon, 02 Jun 2014) Log Message: ----------- improve mind inspector (option to hide annotations, useful with cartaga) Modified Paths: -------------- trunk/src/jason/architecture/MindInspectorAgArch.java trunk/src/jason/control/ExecutionControlGUI.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/util/asl2xml.java trunk/src/xml/agInspection.xsl Modified: trunk/src/jason/architecture/MindInspectorAgArch.java =================================================================== --- trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-02 18:02:23 UTC (rev 1783) +++ trunk/src/jason/architecture/MindInspectorAgArch.java 2014-06-02 21:28:22 UTC (rev 1784) @@ -26,6 +26,8 @@ import jason.asSyntax.ASSyntax; import jason.asSyntax.NumberTerm; import jason.asSyntax.Structure; +import jason.control.ExecutionControlGUI; +import jason.jeditplugin.Config; import jason.util.asl2html; import jason.util.asl2xml; @@ -37,8 +39,10 @@ import java.io.File; import java.io.FileWriter; import java.util.ArrayList; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JCheckBox; @@ -52,6 +56,8 @@ import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; import org.w3c.dom.Document; @@ -63,16 +69,23 @@ // variables for mind inspector protected boolean hasMindInspectorByCycle = false; protected int updateInterval = 0; - protected static JFrame mindInspectorFrame = null; - protected static JTabbedPane mindInspectorTab = null; - protected JTextPane mindInspectorPanel = null; - protected JSlider mindInspectorHistorySlider = null; - protected JCheckBox mindInspectorFreeze = null; - protected List<String> mindInspectorHistory = null; - protected asl2xml mindInspectorTransformer = null; + protected static JFrame mindInspectorFrame = null; + protected static JTabbedPane mindInspectorTab = null; + protected JTextPane mindInspectorPanel = null; + protected JSlider mindInspectorHistorySlider = null; + protected JCheckBox mindInspectorFreeze = null; + protected List<Document> mindInspectorHistory = null; + protected asl2xml mindInspectorTransformer = null; - protected String mindInspectorDirectory; + protected String mindInspectorDirectory; + // Which item is to be shown in HTML interface + Map<String,Boolean> show = new HashMap<String,Boolean>(); + + // what is currently shown + Document agState = null; + + @Override public void init() { setupMindInspector(getTS().getSettings().getUserParameter("mindinspector")); @@ -92,7 +105,7 @@ @Override public void reasoningCycleStarting() { if (hasMindInspectorByCycle) - updateMindInspector(); + addAgState(); super.reasoningCycleStarting(); } @@ -128,7 +141,7 @@ try { while (isRunning()) { Thread.sleep(updateInterval); - updateMindInspector(); + addAgState(); } } catch (Exception e) { e.printStackTrace(); @@ -149,8 +162,8 @@ String format = "text/html"; if (mindInspectorFrame == null) { // Initiate the common window - mindInspectorFrame = new JFrame("Mind Inspector"); - mindInspectorTab = new JTabbedPane(); + mindInspectorFrame = new JFrame(ExecutionControlGUI.title); + mindInspectorTab = new JTabbedPane(JTabbedPane.LEFT); mindInspectorFrame.getContentPane().add(mindInspectorTab); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); mindInspectorFrame.setBounds(100, 200, (int)((screenSize.width-100)*0.7), (int)((screenSize.height-100)*0.9)); @@ -160,13 +173,27 @@ mindInspectorPanel = new JTextPane(); mindInspectorPanel.setEditable(false); mindInspectorPanel.setContentType(format); + mindInspectorPanel.addHyperlinkListener(new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent evt) { + hyperLink(evt); + } + }); + show.put("bels", true); + show.put("annots", Config.get().getBoolean(Config.SHOW_ANNOTS)); + show.put("rules", false); + show.put("evt", true); + show.put("mb", false); + show.put("int", false); + show.put("int-details", false); + show.put("plan", false); + show.put("plan-details", false); // get history boolean hasHistory = sConf.getArity() == 3 && sConf.getTerm(2).toString().equals("history"); if (! hasHistory) { mindInspectorTab.add(getAgName(), new JScrollPane(mindInspectorPanel)); } else { - mindInspectorHistory = new ArrayList<String>(); + mindInspectorHistory = new ArrayList<Document>(); JPanel pHistory = new JPanel(new BorderLayout());//new FlowLayout(FlowLayout.CENTER)); pHistory.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Agent History", TitledBorder.LEFT, TitledBorder.TOP)); mindInspectorHistorySlider = new JSlider(); @@ -182,7 +209,7 @@ public void stateChanged(ChangeEvent e) { try { int c = (int)mindInspectorHistorySlider.getValue(); - mindInspectorPanel.setText(mindInspectorHistory.get(c)); + showAgState(mindInspectorHistory.get(c)); } catch (Exception e2) { } } }); @@ -205,6 +232,26 @@ } } + private void hyperLink(HyperlinkEvent evt) { + if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + String uri = "show?"; + int pos = evt.getDescription().indexOf(uri); + if (pos >= 0) { + String par = evt.getDescription().substring(pos+uri.length()); + show.put(par,true); + } else { + uri = "hide?"; + pos = evt.getDescription().indexOf(uri); + if (pos >= 0) { + String par = evt.getDescription().substring(pos+uri.length()); + show.put(par,false); + } + } + showAgState(agState); + } + } + + private void setupSlider() { int size = mindInspectorHistory.size()-1; @@ -246,22 +293,22 @@ } - private String previousText = ""; + private String lastHistoryText = ""; private int fileCounter = 0; - protected void updateMindInspector() { + + protected void addAgState() { try { - Document agState = getTS().getAg().getAgState(); // the XML representation of the agent's mind - String sMind = mindInspectorTransformer.transform(agState); // transform to HTML - if (sMind.equals(previousText)) - return; // nothing to log - previousText = sMind; + Document state = getTS().getAg().getAgState(); // the XML representation of the agent's mind + String sMind = getAgStateAsString(state, true); + if (sMind.equals(lastHistoryText)) + return; + lastHistoryText = sMind; if (mindInspectorPanel != null) { // output on GUI - if (mindInspectorFreeze == null || !mindInspectorFreeze.isSelected()) { - mindInspectorPanel.setText(sMind); // show the HTML in the screen - } + if (mindInspectorFreeze == null || !mindInspectorFreeze.isSelected()) + showAgState(state); if (mindInspectorHistory != null) { - mindInspectorHistory.add(sMind); + mindInspectorHistory.add(state); setupSlider(); mindInspectorHistorySlider.setValue(mindInspectorHistory.size()-1); } @@ -275,4 +322,38 @@ e.printStackTrace(); } } + + private String previousShownText = ""; + /** show current agent state */ + void showAgState(Document state) { // in GUI + if (state != null) { + try { + String sMind = getAgStateAsString(state, false); + if (sMind.equals(previousShownText)) + return; // nothing to log + previousShownText = sMind; + agState = state; + mindInspectorPanel.setText(sMind); // show the HTML in the screen + } catch (Exception e) { + mindInspectorPanel.setText("Error in XML transformation!" + e); + e.printStackTrace(); + } + } + } + + String getAgStateAsString(Document ag, boolean full) { // full means with show all + try { + for (String p: show.keySet()) + if (full) + mindInspectorTransformer.setParameter("show-"+p, "true"); + else + mindInspectorTransformer.setParameter("show-"+p, show.get(p)+""); + return mindInspectorTransformer.transform(ag); // transform to HTML + } catch (Exception e) { + mindInspectorPanel.setText("Error in XML transformation!" + e); + e.printStackTrace(); + return "Error XML transformation (MindInspector)"; + } + } + } Modified: trunk/src/jason/control/ExecutionControlGUI.java =================================================================== --- trunk/src/jason/control/ExecutionControlGUI.java 2014-06-02 18:02:23 UTC (rev 1783) +++ trunk/src/jason/control/ExecutionControlGUI.java 2014-06-02 21:28:22 UTC (rev 1784) @@ -24,6 +24,7 @@ package jason.control; import jason.infra.centralised.RunCentralisedMAS; +import jason.jeditplugin.Config; import jason.util.asl2html; import jason.util.asl2tex; import jason.util.asl2xml; @@ -124,7 +125,7 @@ // Which item is to be shown in HTML interface Map<String,Boolean> show = new HashMap<String,Boolean>(); - static String title = ":: Jason Mind Inspector ::"; + public static String title = ":: Jason Mind Inspector ::"; void initComponents() { frame = new JFrame(title); @@ -305,6 +306,7 @@ show.put("int-details", false); show.put("plan", false); show.put("plan-details", false); + show.put("annots", Config.get().getBoolean(Config.SHOW_ANNOTS)); } void setListOfAgsFromInfra() { Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-06-02 18:02:23 UTC (rev 1783) +++ trunk/src/jason/jeditplugin/Config.java 2014-06-02 21:28:22 UTC (rev 1784) @@ -77,6 +77,9 @@ public static final String CHECK_VERSION = "checkLatestVersion"; public static final String WARN_SING_VAR = "warnSingletonVars"; + public static final String SHOW_ANNOTS = "showAnnots"; + + public static final String jacamoHomeProp = "JaCaMoHome"; public static final String SHORT_UNNAMED_VARS = "shortUnnamedVars"; @@ -305,7 +308,12 @@ if (getProperty(JADE_RMA) == null) { put(JADE_RMA, "true"); } - + + // show annots + if (getProperty(SHOW_ANNOTS) == null) { + put(SHOW_ANNOTS, "true"); + } + // Default infrastructures put("infrastructure.Centralised", CentralisedFactory.class.getName()); put("infrastructure.Jade", JadeFactory.class.getName()); Modified: trunk/src/jason/util/asl2xml.java =================================================================== --- trunk/src/jason/util/asl2xml.java 2014-06-02 18:02:23 UTC (rev 1783) +++ trunk/src/jason/util/asl2xml.java 2014-06-02 21:28:22 UTC (rev 1784) @@ -81,6 +81,10 @@ return transCache; } + public void setParameter(String name, Object value) { + if (transCache != null) + transCache.setParameter(name, value); + } TransformerFactory fac = null; TransformerFactory getFactory() throws Exception { Modified: trunk/src/xml/agInspection.xsl =================================================================== --- trunk/src/xml/agInspection.xsl 2014-06-02 18:02:23 UTC (rev 1783) +++ trunk/src/xml/agInspection.xsl 2014-06-02 21:28:22 UTC (rev 1784) @@ -21,12 +21,13 @@ <xsl:param name="var" select="'rgb(0, 0, 200)'" /> <xsl:param name="string" select="'rgb(0, 0, 250)'" /> - <xsl:param name="show-bels" select="'true'" /> - <xsl:param name="show-rules" select="'true'" /> - <xsl:param name="show-evt" select="'true'" /> - <xsl:param name="show-mb" select="'true'" /> - <xsl:param name="show-plan" select="'true'" /> - <xsl:param name="show-int" select="'true'" /> + <xsl:param name="show-bels" select="'true'" /> + <xsl:param name="show-annots" select="'true'" /> + <xsl:param name="show-rules" select="'true'" /> + <xsl:param name="show-evt" select="'true'" /> + <xsl:param name="show-mb" select="'true'" /> + <xsl:param name="show-plan" select="'true'" /> + <xsl:param name="show-int" select="'true'" /> <xsl:param name="show-plan-details" select="'true'" /> <xsl:param name="show-int-details" select="'true'" /> @@ -52,6 +53,14 @@ <xsl:apply-templates select="circumstance/actions" /> <!-- xsl:apply-templates select="plans" /--> + <tr style="{$trh-style}"> + <xsl:call-template name="hideshow"> + <xsl:with-param name="show" select="$show-annots" /> + <xsl:with-param name="item" select="'annots'" /> + <xsl:with-param name="ds" select="'Annotations'" /> + </xsl:call-template> + <th/> + </tr> </table> </html> </xsl:template> @@ -61,8 +70,7 @@ <xsl:param name="show" select="'false'" /> <xsl:param name="item" select="'none'" /> <xsl:param name="ds" select="'none'" /> - <xsl:if test="$show='true'"> - + <xsl:if test="$show='true'"> <th valign="top" style="{$th-style}"> <hr/> <a href="hide?{$item}" style="text-decoration: none"> @@ -280,14 +288,17 @@ <xsl:if test="$show-int-details='true'"> <!-- td valign="top" style="{$td-style}" --> <br/> - <xsl:apply-templates select="plan"/> + + <font size="-2"> + <pre> <- ... <xsl:apply-templates select="body"/> </pre> + </font> <!-- /td --> </xsl:if> </td> <xsl:if test="$show-int-details='true'"> <td valign="top" style="{$td-style}"> - <xsl:text> </xsl:text><xsl:text> </xsl:text> + <br/> <xsl:apply-templates select="unifier"/> </td> </xsl:if> @@ -550,11 +561,24 @@ </xsl:template> <xsl:template match="annotations"> + <xsl:if test="$show-annots='true'"> <span style="color: rgb(0 ,190, 0)"> <sub> <xsl:apply-templates /> </sub> - </span> + </span> + </xsl:if> + <xsl:if test="$show-annots='false'"> + <xsl:if test="count(list-term) > 0"> + <sub> + <span style="color: rgb(0 ,0, 200)"> + <a href="show?annots" style="text-decoration: none"> + <xsl:text>[...]</xsl:text> + </a> + </span> + </sub> + </xsl:if> + </xsl:if> </xsl:template> <xsl:template match="var-term"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-02 18:02:27
|
Revision: 1783 http://sourceforge.net/p/jason/svn/1783 Author: jomifred Date: 2014-06-02 18:02:23 +0000 (Mon, 02 Jun 2014) Log Message: ----------- fix bug related to failure plans for test goals Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/environment/Environment.java Modified: trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2014-06-02 17:36:24 UTC (rev 1782) +++ trunk/applications/as-unit-test/src/jason/tests/TestPlanFailure.java 2014-06-02 18:02:23 UTC (rev 1783) @@ -26,7 +26,13 @@ "-!g3(failure)[error(ia_failed)] : true <- infailg3. "+ "+!norel <- !j; endnorel. "+ - "-!j[error(no_relevant)] <- infailj. " + "-!j[error(no_relevant)] <- infailj. " + + + "+!s <- ?bufferReady; jason.asunit.print(ok)." + + "+?bufferReady : a <- jason.asunit.print(oka). " + + "+?bufferReady : not a <- .fail. " + + "-?bufferReady <- jason.asunit.print(w); ?bufferReady." + ); } @@ -46,4 +52,16 @@ ag.assertAct("infailj", 10); ag.assertAct("endnorel", 5); } + + @Test(timeout=2000) + public void testTestGoalFailure() { + ag.addGoal("s"); + ag.assertPrint("w", 10); + ag.assertPrint("w", 10); + ag.assertPrint("w", 10); + ag.addBel("a"); + ag.assertPrint("oka", 10); + ag.assertPrint("ok", 10); + } + } Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-06-02 17:36:24 UTC (rev 1782) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-06-02 18:02:23 UTC (rev 1783) @@ -929,8 +929,8 @@ || im.getCurrentStep().getBodyTerm() instanceof VarTerm) { im = i.pop(); // +!c above } - while (!i.isFinished() && //i.size() > 0 && - !(im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && im.getTrigger().isAchvGoal()) && + while (!i.isFinished() && + !(im.unif.unifies(im.getTrigger().getLiteral(), topLiteral) && im.getTrigger().isGoal()) && !(im.unif.unifies(im.getCurrentStep().getBodyTerm(), topLiteral) && im.getCurrentStep().getBodyType() == BodyType.achieve)) { im = i.pop(); } @@ -952,7 +952,6 @@ // new code optimised: handle directly renamed vars for the call // get vars in the unifier that comes from makeVarAnnon (stored in renamedVars) joinRenamedVarsIntoIntentionUnifier(im,topIM.unif); - im.removeCurrentStep(); } } Modified: trunk/src/jason/environment/Environment.java =================================================================== --- trunk/src/jason/environment/Environment.java 2014-06-02 17:36:24 UTC (rev 1782) +++ trunk/src/jason/environment/Environment.java 2014-06-02 18:02:23 UTC (rev 1783) @@ -375,6 +375,6 @@ */ public boolean executeAction(String agName, Structure act) { logger.info("The action "+act+" done by "+agName+" is not implemented in the default environment."); - return true; + return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-06-02 17:36:28
|
Revision: 1782 http://sourceforge.net/p/jason/svn/1782 Author: jomifred Date: 2014-06-02 17:36:24 +0000 (Mon, 02 Jun 2014) Log Message: ----------- update test Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java Modified: trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java 2014-05-30 01:34:47 UTC (rev 1781) +++ trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java 2014-06-02 17:36:24 UTC (rev 1782) @@ -19,7 +19,7 @@ ); } - @Test(timeout=2000) + @Test(timeout=3000) public void testGoal() { ag.addGoal("start"); ag.assertPrint("10", 10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-30 01:34:53
|
Revision: 1781 http://sourceforge.net/p/jason/svn/1781 Author: jomifred Date: 2014-05-30 01:34:47 +0000 (Fri, 30 May 2014) Log Message: ----------- change updateEvent method to older previous version to keep compatibility Modified Paths: -------------- trunk/src/jason/asSemantics/TransitionSystem.java Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-05-29 22:33:58 UTC (rev 1780) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-05-30 01:34:47 UTC (rev 1781) @@ -1034,34 +1034,30 @@ return ap; } - public boolean updateEvents(List<Literal>[] result, Intention focus) { - if (result == null) return false; + public void updateEvents(List<Literal>[] result, Intention focus) { + if (result == null) return; // create the events - boolean eventProduced = false; for (Literal ladd: result[0]) { Trigger te = new Trigger(TEOperator.add, TEType.belief, ladd); - eventProduced = updateEvents(new Event(te, focus)) || eventProduced; + updateEvents(new Event(te, focus)); focus = Intention.EmptyInt; } for (Literal lrem: result[1]) { Trigger te = new Trigger(TEOperator.del, TEType.belief, lrem); - eventProduced = updateEvents(new Event(te, focus)) || eventProduced; + updateEvents(new Event(te, focus)); focus = Intention.EmptyInt; } - return eventProduced; } // only add External Event if it is relevant in respect to the PlanLibrary - public boolean updateEvents(Event e) { + public void updateEvents(Event e) { // Note: we have to add events even if they are not relevant to // a) allow the user to override selectOption and then provide an "unknown" plan; or then // b) create the failure event (it is done by SelRelPlan) if (e.isInternal() || C.hasListener() || ag.getPL().hasCandidatePlan(e.trigger)) { C.addEvent(e); if (logger.isLoggable(Level.FINE)) logger.fine("Added event " + e+ ", events = "+C.getEvents()); - return true; } - return false; } /** remove the top action and requeue the current intention */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-29 22:34:02
|
Revision: 1780 http://sourceforge.net/p/jason/svn/1780 Author: jomifred Date: 2014-05-29 22:33:58 +0000 (Thu, 29 May 2014) Log Message: ----------- fix a bug related to -bel(X) Modified Paths: -------------- trunk/applications/as-unit-test/src/jason/tests/TestAll.java trunk/src/jason/asSemantics/TransitionSystem.java Added Paths: ----------- trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java Added: trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java (rev 0) +++ trunk/applications/as-unit-test/src/jason/tests/BugDelVar.java 2014-05-29 22:33:58 UTC (rev 1780) @@ -0,0 +1,27 @@ +package jason.tests; + +import jason.asunit.TestAgent; + +import org.junit.Before; +import org.junit.Test; + +public class BugDelVar { + + TestAgent ag; + + @Before + public void setupAg() { + ag = new TestAgent(); + + // defines the agent's AgentSpeak code + ag.parseAScode( + "a(10). +!start <- -a(X); jason.asunit.print(X). " + ); + } + + @Test(timeout=2000) + public void testGoal() { + ag.addGoal("start"); + ag.assertPrint("10", 10); + } +} Modified: trunk/applications/as-unit-test/src/jason/tests/TestAll.java =================================================================== --- trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2014-05-28 03:16:58 UTC (rev 1779) +++ trunk/applications/as-unit-test/src/jason/tests/TestAll.java 2014-05-29 22:33:58 UTC (rev 1780) @@ -16,6 +16,7 @@ BugUnamedVars.class, BugList1.class, BugEval.class, + BugDelVar.class, TestAddLogExprInBB.class, TestGoalSource.class, TestIA.class, Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-05-28 03:16:58 UTC (rev 1779) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-05-29 22:33:58 UTC (rev 1780) @@ -418,6 +418,7 @@ // relevant by chance, so just carry on instead of dropping the // intention confP.C.SI = conf.C.SE.intention; + joinRenamedVarsIntoIntentionUnifier(confP.C.SI.peek(), confP.C.SI.peek().unif); updateIntention(); } else if (setts.requeue()) { // if external, then needs to check settings @@ -871,7 +872,7 @@ // end code for TRO } } - //the code below is done in the PlanBody constructor (to DO it as planbody constructor DOES NOT work) + body = body.forceFullLiteralImpl(); if (!body.hasSource()) { // do not add source(self) in case the programmer set the source body.addAnnot(BeliefBase.TSelf); @@ -950,30 +951,36 @@ // new code optimised: handle directly renamed vars for the call // get vars in the unifier that comes from makeVarAnnon (stored in renamedVars) - if (im.renamedVars != null) { - for (VarTerm ov: im.renamedVars.function.keySet()) { - //System.out.println("looking for a value for "+ov+" in "+im.renamedVars+" and "+topIM.unif); - UnnamedVar vt = (UnnamedVar)im.renamedVars.function.get(ov); - //System.out.println(" via "+vt); - im.unif.unifiesNoUndo(ov, vt); // introduces the renaming in the current unif - // if vt has got a value from the top (a "return" value), include this value in the current unif - Term vl = topIM.unif.function.get(vt); - //System.out.println(ov+"="+vt+"="+vl); - if (vl != null) { // vt has value in top - //System.out.println(" and found "+vl); - vl = vl.capply(topIM.unif); - if (vl.isLiteral()) - ((Literal)vl).makeVarsAnnon(); - im.unif.bind(vt, vl); - } - } - } + joinRenamedVarsIntoIntentionUnifier(im,topIM.unif); + im.removeCurrentStep(); } } } } + private void joinRenamedVarsIntoIntentionUnifier(IntendedMeans im, Unifier values) { + if (im.renamedVars != null) { + for (VarTerm ov: im.renamedVars.function.keySet()) { + //System.out.println("looking for a value for "+ov+" in "+im.renamedVars+" and "+topIM.unif); + UnnamedVar vt = (UnnamedVar)im.renamedVars.function.get(ov); + //System.out.println(" via "+vt); + im.unif.unifiesNoUndo(ov, vt); // introduces the renaming in the current unif + // if vt has got a value from the top (a "return" value), include this value in the current unif + Term vl = values.function.get(vt); + //System.out.println(ov+"="+vt+"="+vl); + if (vl != null) { // vt has value in top + //System.out.println(" and found "+vl); + vl = vl.capply(values); + if (vl.isLiteral()) + ((Literal)vl).makeVarsAnnon(); + im.unif.bind(vt, vl); + } + } + } + + } + /**********************************************/ /* auxiliary functions for the semantic rules */ /**********************************************/ @@ -1027,30 +1034,34 @@ return ap; } - public void updateEvents(List<Literal>[] result, Intention focus) { - if (result == null) return; + public boolean updateEvents(List<Literal>[] result, Intention focus) { + if (result == null) return false; // create the events + boolean eventProduced = false; for (Literal ladd: result[0]) { Trigger te = new Trigger(TEOperator.add, TEType.belief, ladd); - updateEvents(new Event(te, focus)); + eventProduced = updateEvents(new Event(te, focus)) || eventProduced; focus = Intention.EmptyInt; } for (Literal lrem: result[1]) { Trigger te = new Trigger(TEOperator.del, TEType.belief, lrem); - updateEvents(new Event(te, focus)); + eventProduced = updateEvents(new Event(te, focus)) || eventProduced; focus = Intention.EmptyInt; } + return eventProduced; } // only add External Event if it is relevant in respect to the PlanLibrary - public void updateEvents(Event e) { + public boolean updateEvents(Event e) { // Note: we have to add events even if they are not relevant to // a) allow the user to override selectOption and then provide an "unknown" plan; or then // b) create the failure event (it is done by SelRelPlan) if (e.isInternal() || C.hasListener() || ag.getPL().hasCandidatePlan(e.trigger)) { C.addEvent(e); if (logger.isLoggable(Level.FINE)) logger.fine("Added event " + e+ ", events = "+C.getEvents()); + return true; } + return false; } /** remove the top action and requeue the current intention */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-28 03:17:01
|
Revision: 1779 http://sourceforge.net/p/jason/svn/1779 Author: jomifred Date: 2014-05-28 03:16:58 +0000 (Wed, 28 May 2014) Log Message: ----------- improve autodetection of user configuration Modified Paths: -------------- trunk/src/jason/jeditplugin/Config.java Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-05-25 15:41:39 UTC (rev 1778) +++ trunk/src/jason/jeditplugin/Config.java 2014-05-28 03:16:58 UTC (rev 1779) @@ -32,6 +32,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; +import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; @@ -98,7 +99,7 @@ return singleton; } - private Config() { + protected Config() { } /** returns the file where the user preferences are stored */ @@ -109,6 +110,10 @@ public File getMasterConfFile() { return new File("jason.properties"); } + + public String getFileConfComment() { + return "Jason user configuration"; + } /** Returns true if the file is loaded correctly */ public boolean load() { @@ -253,6 +258,11 @@ antlib = new File(".") + File.separator + "lib"; if (checkAntLib(antlib)) { setAntLib(antlib); + } else { + antlib = new File("..") + File.separator + "lib"; + if (checkAntLib(antlib)) { + setAntLib(antlib); + } } } } catch (Exception e) { @@ -304,13 +314,16 @@ } public void store() { + store(getUserConfFile()); + } + + public void store(File f) { try { - File f = getUserConfFile(); if (!f.getParentFile().exists()) { f.getParentFile().mkdirs(); } System.out.println("Storing configuration at "+f); - super.store(new FileOutputStream(f), "Jason user configuration"); + super.store(new FileOutputStream(f), getFileConfComment()); } catch (Exception e) { System.err.println("Error writting preferences"); e.printStackTrace(); @@ -360,8 +373,16 @@ Properties p = new Properties(); p.load(Config.class.getResource("/dist.properties").openStream()); return p.getProperty("version") + "." + p.getProperty("release"); - } catch (Exception ex) { - return "?"; + } catch (Exception ex1) { + try { + Properties p = new Properties(); + System.out.println("try 2"); + p.load(new FileReader("bin/dist.properties")); + return p.getProperty("version") + "." + p.getProperty("release"); + } catch (Exception ex2) { + System.out.println("*"+ex2); + return "?"; + } } } @@ -390,31 +411,47 @@ // try current dir jarFile = "." + File.separator + jarName; if (checkJar(jarFile, minSize)) { - put(jarEntry, new File(jarFile).getAbsolutePath()); - System.out.println("found at " + jarFile); - return; + try { + put(jarEntry, new File(jarFile).getCanonicalFile().getAbsolutePath()); + System.out.println("found at " + jarFile); + return; + } catch (IOException e) { + e.printStackTrace(); + } } // try current dir + lib jarFile = ".." + File.separator + "lib" + File.separator + jarName; if (checkJar(jarFile, minSize)) { - put(jarEntry, new File(jarFile).getAbsolutePath()); - System.out.println("found at " + jarFile); - return; + try { + put(jarEntry, new File(jarFile).getCanonicalFile().getAbsolutePath()); + System.out.println("found at " + jarFile); + return; + } catch (IOException e) { + e.printStackTrace(); + } } jarFile = "." + File.separator + "lib" + File.separator + jarName; if (checkJar(jarFile, minSize)) { - put(jarEntry, new File(jarFile).getAbsolutePath()); - System.out.println("found at " + jarFile); - return; + try { + put(jarEntry, new File(jarFile).getCanonicalFile().getAbsolutePath()); + System.out.println("found at " + jarFile); + return; + } catch (IOException e) { + e.printStackTrace(); + } } // try current dir + bin jarFile = "." + File.separator + "bin" + File.separator + jarName; if (checkJar(jarFile, minSize)) { - put(jarEntry, new File(jarFile).getAbsolutePath()); - System.out.println("found at " + jarFile); - return; + try { + put(jarEntry, new File(jarFile).getCanonicalFile().getAbsolutePath()); + System.out.println("found at " + jarFile); + return; + } catch (IOException e) { + e.printStackTrace(); + } } // try from java web start This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-25 15:41:42
|
Revision: 1778 http://sourceforge.net/p/jason/svn/1778 Author: jomifred Date: 2014-05-25 15:41:39 +0000 (Sun, 25 May 2014) Log Message: ----------- improve Config Modified Paths: -------------- trunk/src/jason/jeditplugin/Config.java Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-05-25 15:26:46 UTC (rev 1777) +++ trunk/src/jason/jeditplugin/Config.java 2014-05-25 15:41:39 UTC (rev 1778) @@ -217,22 +217,27 @@ tryToFixJarFileConf(JADE_JAR, "jade.jar", 2000000); tryToFixJarFileConf(MOISE_JAR, "moise.jar", 300000); tryToFixJarFileConf(JACAMO_JAR, "jacamo.jar", 5000); - + // fix java home if (get(JAVA_HOME) == null || !checkJavaHomePath(getProperty(JAVA_HOME))) { String javaHome = System.getProperty("java.home"); if (checkJavaHomePath(javaHome)) { setJavaHome(javaHome); } else { - String javaHomeUp = javaHome + File.separator + ".."; - if (checkJavaHomePath(javaHomeUp)) { - setJavaHome(javaHomeUp); - } else { - // try JRE - if (checkJREHomePath(javaHome)) { - setJavaHome(javaHome); - } else { - setJavaHome(File.separator); + String javaEnvHome = System.getenv("JAVA_HOME"); + if (javaEnvHome != null && checkJavaHomePath(javaEnvHome)) { + setJavaHome(javaEnvHome); + } else { + String javaHomeUp = javaHome + File.separator + ".."; + if (checkJavaHomePath(javaHomeUp)) { + setJavaHome(javaHomeUp); + } else { + // try JRE + if (checkJREHomePath(javaHome)) { + setJavaHome(javaHome); + } else { + setJavaHome(File.separator); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-25 15:26:49
|
Revision: 1777 http://sourceforge.net/p/jason/svn/1777 Author: jomifred Date: 2014-05-25 15:26:46 +0000 (Sun, 25 May 2014) Log Message: ----------- improve java home detection for Config Modified Paths: -------------- trunk/lib/c4jason.jar trunk/lib/cartago.jar trunk/lib/moise.jar trunk/src/jason/jeditplugin/Config.java trunk/src/jason/util/ConfigGUI.java Modified: trunk/lib/c4jason.jar =================================================================== (Binary files differ) Modified: trunk/lib/cartago.jar =================================================================== (Binary files differ) Modified: trunk/lib/moise.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-05-12 13:39:52 UTC (rev 1776) +++ trunk/src/jason/jeditplugin/Config.java 2014-05-25 15:26:46 UTC (rev 1777) @@ -224,7 +224,17 @@ if (checkJavaHomePath(javaHome)) { setJavaHome(javaHome); } else { - setJavaHome(File.separator); + String javaHomeUp = javaHome + File.separator + ".."; + if (checkJavaHomePath(javaHomeUp)) { + setJavaHome(javaHomeUp); + } else { + // try JRE + if (checkJREHomePath(javaHome)) { + setJavaHome(javaHome); + } else { + setJavaHome(File.separator); + } + } } } @@ -478,6 +488,21 @@ return false; } + public static boolean checkJREHomePath(String javaHome) { + try { + if (!javaHome.endsWith(File.separator)) { + javaHome += File.separator; + } + File javac1 = new File(javaHome + "bin" + File.separatorChar + "java"); + File javac2 = new File(javaHome + "bin" + File.separatorChar + "java.exe"); + if (javac1.exists() || javac2.exists()) { + return true; + } + } catch (Exception e) { + } + return false; + } + public static boolean checkAntLib(String al) { try { if (!al.endsWith(File.separator)) { Modified: trunk/src/jason/util/ConfigGUI.java =================================================================== --- trunk/src/jason/util/ConfigGUI.java 2014-05-12 13:39:52 UTC (rev 1776) +++ trunk/src/jason/util/ConfigGUI.java 2014-05-25 15:26:46 UTC (rev 1777) @@ -356,7 +356,7 @@ userProperties.put(Config.JASON_JAR, jasonTF.getText().trim()); } - if (Config.checkJavaHomePath(javaTF.getText())) { + if (Config.checkJavaHomePath(javaTF.getText()) || Config.checkJREHomePath(javaTF.getText())) { userProperties.setJavaHome(javaTF.getText().trim()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-05-12 13:39:55
|
Revision: 1776 http://sourceforge.net/p/jason/svn/1776 Author: jomifred Date: 2014-05-12 13:39:52 +0000 (Mon, 12 May 2014) Log Message: ----------- fix bug reported by Alejandro Guerra Hern?\195?\161ndez related to sources Modified Paths: -------------- trunk/doc/mini-tutorial/src/getting-started/greeting/greeting.mas2j trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/asSyntax/PlanBodyImpl.java trunk/src/test/ASParserTest.java trunk/src/test/PlanTest.java Modified: trunk/doc/mini-tutorial/src/getting-started/greeting/greeting.mas2j =================================================================== --- trunk/doc/mini-tutorial/src/getting-started/greeting/greeting.mas2j 2014-04-25 21:04:48 UTC (rev 1775) +++ trunk/doc/mini-tutorial/src/getting-started/greeting/greeting.mas2j 2014-05-12 13:39:52 UTC (rev 1776) @@ -2,7 +2,7 @@ MAS greeting { - infrastructure: Jade + infrastructure: Centralised agents: bob; Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-04-25 21:04:48 UTC (rev 1775) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-05-12 13:39:52 UTC (rev 1776) @@ -51,6 +51,7 @@ import jason.asSyntax.UnnamedVar; import jason.asSyntax.VarTerm; import jason.asSyntax.parser.ParseException; +import jason.bb.BeliefBase; import jason.runtime.Settings; import jason.stdlib.add_nested_source; import jason.stdlib.desire; @@ -317,7 +318,7 @@ getAg().addBel((Literal)content); added = true; } - } + } if (!added) { Literal received = new LiteralImpl(Message.kqmlReceivedFunctor).addTerms( @@ -617,7 +618,7 @@ PlanBody h = im.getCurrentStep(); Term bTerm = h.getBodyTerm(); - + if (bTerm instanceof VarTerm) { // de-var bTerm bTerm = bTerm.capply(u); if (bTerm.isVar()) { // the case of !A with A not ground @@ -870,11 +871,11 @@ // end code for TRO } } - //the code below is done in the PlanBody constructor - //body = body.forceFullLiteralImpl(); - //if (!body.hasSource()) { // do not add source(self) in case the programmer set the source - // body.addAnnot(BeliefBase.TSelf); - //} + //the code below is done in the PlanBody constructor (to DO it as planbody constructor DOES NOT work) + body = body.forceFullLiteralImpl(); + if (!body.hasSource()) { // do not add source(self) in case the programmer set the source + body.addAnnot(BeliefBase.TSelf); + } return body; } Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java =================================================================== --- trunk/src/jason/asSyntax/PlanBodyImpl.java 2014-04-25 21:04:48 UTC (rev 1775) +++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2014-05-12 13:39:52 UTC (rev 1776) @@ -2,7 +2,6 @@ import jason.asSemantics.Agent; import jason.asSemantics.Unifier; -import jason.bb.BeliefBase; import java.util.Iterator; import java.util.logging.Level; @@ -56,7 +55,9 @@ if (b != null) { srcInfo = b.getSrcInfo(); + /* // add source(self) in some commands (it is preferred to do this at compile time than runtime) + // DOES NOT work with variables (see the case of kqmlPlans.asl and the bug reported by Alexandro) if (b instanceof Literal) { switch (formType) { case achieve: @@ -79,6 +80,7 @@ break; } } + */ } term = b; } Modified: trunk/src/test/ASParserTest.java =================================================================== --- trunk/src/test/ASParserTest.java 2014-04-25 21:04:48 UTC (rev 1775) +++ trunk/src/test/ASParserTest.java 2014-05-12 13:39:52 UTC (rev 1776) @@ -13,7 +13,6 @@ import jason.asSyntax.LogExpr; import jason.asSyntax.LogicalFormula; import jason.asSyntax.NumberTerm; -import jason.asSyntax.NumberTermImpl; import jason.asSyntax.Plan; import jason.asSyntax.PlanBody; import jason.asSyntax.PlanBody.BodyType; @@ -221,7 +220,7 @@ public void testParsingPlanBodyTerm1() throws ParseException { Literal l = ASSyntax.parseLiteral("p( {a1({f}); a2}, a3, {!g}, {?b;.print(oi) }, 10)"); - assertEquals("p({ a1({ f }); a2 },a3,{ !g[source(self)] },{ ?b; .print(oi) },10)", l.toString()); + assertEquals("p({ a1({ f }); a2 },a3,{ !g },{ ?b; .print(oi) },10)", l.toString()); assertEquals(5,l.getArity()); assertTrue(l.getTerm(0) instanceof PlanBody); assertTrue(l.getTerm(0).isPlanBody()); @@ -251,7 +250,7 @@ Unifier un = new Unifier(); Term t = ASSyntax.parseTerm("{ +a(10) }"); assertTrue(t.isPlanBody()); - assertEquals("{ +a(10)[source(self)] }", t.toString()); // plan terms should not have default annotations + assertEquals("{ +a(10) }", t.toString()); // plan terms should not have default annotations t = ASSyntax.parseTerm("{ @label(a,b,10,test,long,label) +a(10) }"); assertTrue(t instanceof Plan); @@ -259,10 +258,10 @@ t = ASSyntax.parseTerm("{ -+a(10) }"); assertTrue(t.isPlanBody()); - assertEquals("{ -+a(10)[source(self)] }", t.toString()); + assertEquals("{ -+a(10) }", t.toString()); t = ASSyntax.parseTerm("{ -a; +b }"); - assertEquals("{ -a[source(self)]; +b[source(self)] }", t.toString()); + assertEquals("{ -a; +b }", t.toString()); assertTrue(t.isPlanBody()); PlanBody pb = (PlanBody)t; assertEquals(2, pb.getPlanSize()); @@ -285,18 +284,18 @@ assertTrue(t.isPlanBody()); pb = (PlanBody)t; assertEquals(1, pb.getPlanSize()); - assertEquals("a[source(self)]", pb.getBodyTerm().toString()); + assertEquals("a", pb.getBodyTerm().toString()); assertEquals(PlanBody.BodyType.achieve, pb.getBodyType()); t = ASSyntax.parseTerm("{ +!a <- +b }"); - assertEquals("{ +!a <- +b[source(self)] }", t.toString()); + assertEquals("{ +!a <- +b }", t.toString()); assertTrue(t.isStructure()); s = (Structure)t; assertEquals(4, s.getArity()); assertEquals("plan", s.getFunctor()); t = ASSyntax.parseTerm("{ +a <- +c }"); - assertEquals("{ +a <- +c[source(self)] }", t.toString()); + assertEquals("{ +a <- +c }", t.toString()); assertTrue(t.isStructure()); s = (Structure)t; assertEquals(4, s.getArity()); Modified: trunk/src/test/PlanTest.java =================================================================== --- trunk/src/test/PlanTest.java 2014-04-25 21:04:48 UTC (rev 1775) +++ trunk/src/test/PlanTest.java 2014-05-12 13:39:52 UTC (rev 1776) @@ -108,9 +108,9 @@ //assertEquals(p1.getBody().getArity(), bl.getArity()); Unifier u = new Unifier(); assertTrue(u.unifies(p1.getBody(), bl)); - assertEquals("a1[source(self)]", u.get("A1").toString()); + assertEquals("a1", u.get("A1").toString()); assertEquals("a2", u.get("A2").toString()); - assertEquals(".print(a); !g1[source(self)]", u.get("A3").toString()); + assertEquals(".print(a); !g1", u.get("A3").toString()); } public void testPlanTermWithVarBody() throws ParseException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-04-25 21:04:51
|
Revision: 1775 http://sourceforge.net/p/jason/svn/1775 Author: jomifred Date: 2014-04-25 21:04:48 +0000 (Fri, 25 Apr 2014) Log Message: ----------- fix initial bels from project (add source and allows atoms) Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-04-23 13:24:33 UTC (rev 1774) +++ trunk/src/jason/asSemantics/Agent.java 2014-04-25 21:04:48 UTC (rev 1775) @@ -504,7 +504,10 @@ if (sBels != null) { try { for (Term t: ASSyntax.parseList("["+sBels+"]")) { - getBB().add((Literal)t); + Literal b = ((Literal)t).forceFullLiteralImpl(); + if (!b.hasSource()) + b.addAnnot(BeliefBase.TSelf); + getBB().add(b); } } catch (Exception e) { logger.log(Level.WARNING, "Initial beliefs from project '["+sBels+"]' is not a list of literals."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-04-23 13:24:36
|
Revision: 1774 http://sourceforge.net/p/jason/svn/1774 Author: jomifred Date: 2014-04-23 13:24:33 +0000 (Wed, 23 Apr 2014) Log Message: ----------- fix a bug related to parsing messages as reported and fixed by Lucas W. Hilgert Modified Paths: -------------- trunk/src/jason/asSemantics/Message.java Modified: trunk/src/jason/asSemantics/Message.java =================================================================== --- trunk/src/jason/asSemantics/Message.java 2014-04-20 23:30:57 UTC (rev 1773) +++ trunk/src/jason/asSemantics/Message.java 2014-04-23 13:24:33 UTC (rev 1774) @@ -164,7 +164,7 @@ if (msg.startsWith("<")) { one = msg.indexOf(","); int arrowIndex = msg.indexOf("->"); - if (one > arrowIndex) { // If there is an arrow before the first comma + if ((arrowIndex > 0) && (one > arrowIndex)) { // If there is an arrow before the first comma newmsg.msgId = msg.substring(1, arrowIndex); newmsg.inReplyTo = msg.substring(arrowIndex + 2, one); } else { // If not (either there is no arrow, or there is one behind the first comma) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-04-20 23:31:01
|
Revision: 1773 http://sourceforge.net/p/jason/svn/1773 Author: jomifred Date: 2014-04-20 23:30:57 +0000 (Sun, 20 Apr 2014) Log Message: ----------- .concat also accept terms as first argument Modified Paths: -------------- trunk/src/jason/stdlib/concat.java Modified: trunk/src/jason/stdlib/concat.java =================================================================== --- trunk/src/jason/stdlib/concat.java 2014-04-20 21:52:15 UTC (rev 1772) +++ trunk/src/jason/stdlib/concat.java 2014-04-20 23:30:57 UTC (rev 1773) @@ -101,7 +101,7 @@ return un.unifies(result, args[args.length-1]); - } else if (args[0].isString()) { + } else { //if (args[0].isString() || args) { // string concat if (!args[args.length-1].isVar() && !args[args.length-1].isString()) { throw JasonException.createWrongArgument(this,"Last argument '"+args[args.length-1]+"' is not a string nor a variable."); @@ -119,8 +119,8 @@ sr.append(vl); } return un.unifies(new StringTermImpl(sr.toString()), args[args.length-1]); - } else { - throw JasonException.createWrongArgument(this,"First argument '"+args[0]+"' must be a list or string."); + //} else { + // throw JasonException.createWrongArgument(this,"First argument '"+args[0]+"' must be a list, string or term."); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-04-20 21:52:19
|
Revision: 1772 http://sourceforge.net/p/jason/svn/1772 Author: jomifred Date: 2014-04-20 21:52:15 +0000 (Sun, 20 Apr 2014) Log Message: ----------- fix problem in MASConsoleColorGUI Modified Paths: -------------- trunk/src/jason/architecture/AgArch.java trunk/src/jason/asSemantics/TransitionSystem.java trunk/src/jason/bb/JDBCPersistentBB.java trunk/src/jason/runtime/MASConsoleColorGUI.java Modified: trunk/src/jason/architecture/AgArch.java =================================================================== --- trunk/src/jason/architecture/AgArch.java 2014-03-31 17:43:53 UTC (rev 1771) +++ trunk/src/jason/architecture/AgArch.java 2014-04-20 21:52:15 UTC (rev 1772) @@ -201,7 +201,7 @@ * Executes the action <i>action</i> and, when finished, add it back in * <i>feedback</i> actions. */ - // TODO: remove feedback parameter and use getTS().addFeedbackAction + // TODO: remove feedback parameter and use getTS().addFeedbackAction in a new method of this class to be executed when the action is finished (as actionExecuted of centralised) // for jason 2.0 to avoid backward compatibility problems public void act(ActionExec action, List<ActionExec> feedback) { if (successor != null) Modified: trunk/src/jason/asSemantics/TransitionSystem.java =================================================================== --- trunk/src/jason/asSemantics/TransitionSystem.java 2014-03-31 17:43:53 UTC (rev 1771) +++ trunk/src/jason/asSemantics/TransitionSystem.java 2014-04-20 21:52:15 UTC (rev 1772) @@ -858,7 +858,11 @@ //System.out.println("adding "+t+"="+renamedVars.function.get(v)); if (adds == null) adds = new HashMap<VarTerm, Term>(); - adds.put((VarTerm)t,renamedVars.function.get(v)); + try { + adds.put((VarTerm)t,renamedVars.function.get(v)); + } catch (Exception e) { + logger.log(Level.SEVERE, "*** Error adding var into renamed vars. var="+v+", value="+t+".", e); + } } } if (adds != null) Modified: trunk/src/jason/bb/JDBCPersistentBB.java =================================================================== --- trunk/src/jason/bb/JDBCPersistentBB.java 2014-03-31 17:43:53 UTC (rev 1771) +++ trunk/src/jason/bb/JDBCPersistentBB.java 2014-04-20 21:52:15 UTC (rev 1772) @@ -371,8 +371,9 @@ return iterator(); } else { // get all rows of l's table + String q = null; try { - String q = getSelect(l); + q = getSelect(l); if (logger.isLoggable(Level.FINE)) logger.fine("getRelevant query for "+l+": "+q); final ResultSet rs = conn.createStatement().executeQuery(q); return new Iterator<Literal>() { @@ -409,7 +410,7 @@ } }; } catch (SQLException e) { - logger.log(Level.SEVERE, "SQL Error in getRelevant for "+l, e); + logger.log(Level.SEVERE, "SQL Error in getRelevant for "+l+" with query "+q, e); } } return null; Modified: trunk/src/jason/runtime/MASConsoleColorGUI.java =================================================================== --- trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-03-31 17:43:53 UTC (rev 1771) +++ trunk/src/jason/runtime/MASConsoleColorGUI.java 2014-04-20 21:52:15 UTC (rev 1772) @@ -48,7 +48,7 @@ output.setEditable(false); ((DefaultCaret)output.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); if (isTabbed()) { - tabPane.add("common", new JScrollPane(output)); + tabPane.add(" all", new JScrollPane(output)); } else { pcenter.add(BorderLayout.CENTER, new JScrollPane(output)); } @@ -75,10 +75,18 @@ if (isTabbed() && agName != null) { MASColorTextPane ta = agsTextArea.get(agName); if (ta == null) { - ta = new MASColorTextPane(c); - ta.setEditable(false); - agsTextArea.put(agName, ta); - tabPane.add(agName, new JScrollPane(ta)); + synchronized (this) { + ta = new MASColorTextPane(Color.black); + ta.setEditable(false); + agsTextArea.put(agName, ta); + int i = 0; + for (; i<tabPane.getTabCount(); i++) { + if (agName.toUpperCase().compareTo( tabPane.getTitleAt(i).toUpperCase()) < 0) + break; + } + tabPane.add(new JScrollPane(ta),i); + tabPane.setTitleAt(i, agName); + } } if (ta != null) { // no new TA was created // print out @@ -124,7 +132,7 @@ protected static int change = 0; protected static int lastColor = 0; - public static Color getNextAvailableColor() { + public synchronized static Color getNextAvailableColor() { if(change > 0) { seq[lastColor] = (change%2 == 1)?seq[lastColor].brighter():seq[lastColor].darker(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-03-31 17:43:58
|
Revision: 1771 http://sourceforge.net/p/jason/svn/1771 Author: jomifred Date: 2014-03-31 17:43:53 +0000 (Mon, 31 Mar 2014) Log Message: ----------- revert last change in DefaultTerm Modified Paths: -------------- trunk/lib/c4jason.jar trunk/src/jason/asSyntax/DefaultTerm.java Modified: trunk/lib/c4jason.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/asSyntax/DefaultTerm.java =================================================================== --- trunk/src/jason/asSyntax/DefaultTerm.java 2014-03-31 14:16:09 UTC (rev 1770) +++ trunk/src/jason/asSyntax/DefaultTerm.java 2014-03-31 17:43:53 UTC (rev 1771) @@ -32,8 +32,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import c4jason.ToProlog; - /** * Base class for all terms. * @@ -45,7 +43,7 @@ * * @see ASSyntax */ -public abstract class DefaultTerm implements Term, Serializable, ToProlog { +public abstract class DefaultTerm implements Term, Serializable { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(Term.class.getName()); @@ -130,9 +128,4 @@ else return srcInfo.toString(); } - - @Override - public String getAsPrologStr() { - return toString(); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2014-03-31 14:16:14
|
Revision: 1770 http://sourceforge.net/p/jason/svn/1770 Author: jomifred Date: 2014-03-31 14:16:09 +0000 (Mon, 31 Mar 2014) Log Message: ----------- implement ToProlog (from cartago) in Jason classes Modified Paths: -------------- trunk/demos/persistent-belief-base/bookstore.properties trunk/demos/persistent-belief-base/bookstore.script trunk/demos/persistent-belief-base/c.asl trunk/lib/moise.jar trunk/src/jason/asSyntax/DefaultTerm.java Modified: trunk/demos/persistent-belief-base/bookstore.properties =================================================================== --- trunk/demos/persistent-belief-base/bookstore.properties 2013-12-20 17:59:14 UTC (rev 1769) +++ trunk/demos/persistent-belief-base/bookstore.properties 2014-03-31 14:16:09 UTC (rev 1770) @@ -1,5 +1,5 @@ #HSQL Database Engine -#Mon Jun 13 10:20:47 BRT 2011 +#Tue Jan 21 16:04:05 BRST 2014 hsqldb.script_format=0 runtime.gc_interval=0 sql.enforce_strict_size=false Modified: trunk/demos/persistent-belief-base/bookstore.script =================================================================== --- trunk/demos/persistent-belief-base/bookstore.script 2013-12-20 17:59:14 UTC (rev 1769) +++ trunk/demos/persistent-belief-base/bookstore.script 2014-03-31 14:16:09 UTC (rev 1770) @@ -28,4 +28,4 @@ INSERT INTO PUBLISHER VALUES(1,'Springer') INSERT INTO PUBLISHER VALUES(2,'MIT Press') INSERT INTO PUBLISHER VALUES(3,'John Wiley & Sons') -INSERT INTO TABLEA VALUES('54',FALSE,'[source(self)]') +INSERT INTO TABLEA VALUES('56',FALSE,'[source(self)]') Modified: trunk/demos/persistent-belief-base/c.asl =================================================================== --- trunk/demos/persistent-belief-base/c.asl 2013-12-20 17:59:14 UTC (rev 1769) +++ trunk/demos/persistent-belief-base/c.asl 2014-03-31 14:16:09 UTC (rev 1770) @@ -6,7 +6,7 @@ +!start : a(X) <- -+a(X+1); // a is stored in a DB - .print("Not first run, I already run ",X," times."); + .print("It is not my first run, I already run ",X," times."); !show_book(X); .println; .print("All titles:"); ?show_all_titles. @@ -32,3 +32,4 @@ // Rules used to show all books show_all_titles :- book(_, Title, _, _Year, _ISBN) & .println("-- ", Title) & false. show_all_titles :- true. + Modified: trunk/lib/moise.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/asSyntax/DefaultTerm.java =================================================================== --- trunk/src/jason/asSyntax/DefaultTerm.java 2013-12-20 17:59:14 UTC (rev 1769) +++ trunk/src/jason/asSyntax/DefaultTerm.java 2014-03-31 14:16:09 UTC (rev 1770) @@ -32,6 +32,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import c4jason.ToProlog; + /** * Base class for all terms. * @@ -43,7 +45,7 @@ * * @see ASSyntax */ -public abstract class DefaultTerm implements Term, Serializable { +public abstract class DefaultTerm implements Term, Serializable, ToProlog { private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger(Term.class.getName()); @@ -128,4 +130,9 @@ else return srcInfo.toString(); } + + @Override + public String getAsPrologStr() { + return toString(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2013-12-20 17:59:18
|
Revision: 1769 http://sourceforge.net/p/jason/svn/1769 Author: jomifred Date: 2013-12-20 17:59:14 +0000 (Fri, 20 Dec 2013) Log Message: ----------- remove auto source(self) from triggers in planterms Modified Paths: -------------- trunk/src/jason/asSyntax/PlanBodyImpl.java trunk/src/jason/asSyntax/Trigger.java trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc trunk/src/jason/asSyntax/parser/as2j.java trunk/src/test/ASParserTest.java Modified: trunk/src/jason/asSyntax/PlanBodyImpl.java =================================================================== --- trunk/src/jason/asSyntax/PlanBodyImpl.java 2013-12-17 18:46:59 UTC (rev 1768) +++ trunk/src/jason/asSyntax/PlanBodyImpl.java 2013-12-20 17:59:14 UTC (rev 1769) @@ -41,15 +41,24 @@ super(BODY_PLAN_FUNCTOR, 0); } + public PlanBodyImpl(boolean planTerm) { + this(); + setAsBodyTerm(planTerm); + } + public PlanBodyImpl(BodyType t, Term b) { - super(BODY_PLAN_FUNCTOR, 0); + this(t,b,false); + } + + public PlanBodyImpl(BodyType t, Term b, boolean planTerm) { + this(planTerm); formType = t; if (b != null) { srcInfo = b.getSrcInfo(); // add source(self) in some commands (it is preferred to do this at compile time than runtime) if (b instanceof Literal) { - switch (t) { + switch (formType) { case achieve: case achieveNF: case addBel: @@ -309,15 +318,15 @@ PlanBodyImpl c; if (term == null) { // (NIDE) must copy c.isTerm even if cloning empty plan c = new PlanBodyImpl(); + c.isTerm = isTerm; } else { - c = new PlanBodyImpl(formType, term.capply(u)); + c = new PlanBodyImpl(formType, term.capply(u), isTerm); if (c.term.isPlanBody()) { // we cannot have "inner" body literals c.formType = ((PlanBody)c.term).getBodyType(); c.next = ((PlanBody)c.term).getBodyNext(); c.term = ((PlanBody)c.term).getBodyTerm(); } } - c.isTerm = isTerm; if (next != null) c.add((PlanBody)next.capply(u)); @@ -331,7 +340,7 @@ if (term == null) // (NIDE) must copy c.isTerm even if cloning empty plan c = new PlanBodyImpl(); else - c = new PlanBodyImpl(formType, term.clone()); + c = new PlanBodyImpl(formType, term.clone(), isTerm); c.isTerm = isTerm; if (next != null) c.setBodyNext(getBodyNext().clonePB()); Modified: trunk/src/jason/asSyntax/Trigger.java =================================================================== --- trunk/src/jason/asSyntax/Trigger.java 2013-12-17 18:46:59 UTC (rev 1768) +++ trunk/src/jason/asSyntax/Trigger.java 2013-12-20 17:59:14 UTC (rev 1769) @@ -28,6 +28,7 @@ import jason.asSyntax.PlanBody.BodyType; import jason.asSyntax.parser.ParseException; import jason.asSyntax.parser.as2j; +import jason.bb.BeliefBase; import java.io.StringReader; import java.util.logging.Level; @@ -220,27 +221,25 @@ if (t instanceof Trigger) { return (Trigger)t; } - /*if (t instanceof VarTerm) { - VarTerm v = (VarTerm)t; - if (v.hasValue() && v.getValue() instanceof Trigger) { - return (Trigger)v.getValue(); - } - if (v.hasValue() && v.getValue() instanceof Plan) { - return ((Plan)v.getValue()).getTrigger(); - } - }*/ - if (t.isString()) { - return ASSyntax.parseTrigger(((StringTerm)t).getString()); - } if (t.isPlanBody()) { PlanBody p = (PlanBody)t; if (p.getPlanSize() == 1) { - if (p.getBodyType() == BodyType.addBel) - return new Trigger(TEOperator.add, TEType.belief, (Literal)p.getBodyTerm()); - if (p.getBodyType() == BodyType.delBel) - return new Trigger(TEOperator.del, TEType.belief, (Literal)p.getBodyTerm()); + TEOperator op = null; + if (p.getBodyType() == BodyType.addBel) + op = TEOperator.add; + else if (p.getBodyType() == BodyType.delBel) + op = TEOperator.del; + if (op != null) { + Literal l = (Literal)p.getBodyTerm().clone(); + l.delAnnot(BeliefBase.TSelf); // remove the eventual auto added annotation of source + return new Trigger(op, TEType.belief, l); + + } } } + if (t.isString()) { + return ASSyntax.parseTrigger(((StringTerm)t).getString()); + } return null; } Modified: trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc =================================================================== --- trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2013-12-17 18:46:59 UTC (rev 1768) +++ trunk/src/jason/asSyntax/parser/AS2JavaParser.jcc 2013-12-20 17:59:14 UTC (rev 1769) @@ -510,10 +510,9 @@ // handle the case of "+a1; +a2", parsed as "TE; Body" if (pb && L == null) { if (T.isAddition()) - B1 = new PlanBodyImpl(BodyType.addBel, T.getLiteral()); + B1 = new PlanBodyImpl(BodyType.addBel, T.getLiteral(), true); else - B1 = new PlanBodyImpl(BodyType.delBel, T.getLiteral()); - B1.setAsBodyTerm(true); + B1 = new PlanBodyImpl(BodyType.delBel, T.getLiteral(), true); if (B != null) B1.setBodyNext(B); return B1; Modified: trunk/src/jason/asSyntax/parser/as2j.java =================================================================== --- trunk/src/jason/asSyntax/parser/as2j.java 2013-12-17 18:46:59 UTC (rev 1768) +++ trunk/src/jason/asSyntax/parser/as2j.java 2013-12-20 17:59:14 UTC (rev 1769) @@ -778,10 +778,9 @@ // handle the case of "+a1; +a2", parsed as "TE; Body" if (pb && L == null) { if (T.isAddition()) - B1 = new PlanBodyImpl(BodyType.addBel, T.getLiteral()); + B1 = new PlanBodyImpl(BodyType.addBel, T.getLiteral(), true); else - B1 = new PlanBodyImpl(BodyType.delBel, T.getLiteral()); - B1.setAsBodyTerm(true); + B1 = new PlanBodyImpl(BodyType.delBel, T.getLiteral(), true); if (B != null) B1.setBodyNext(B); {if (true) return B1;} @@ -1531,13 +1530,18 @@ return false; } + final private boolean jj_3R_66() { + if (jj_3R_78()) return true; + return false; + } + final private boolean jj_3R_85() { if (jj_3R_91()) return true; return false; } - final private boolean jj_3R_66() { - if (jj_3R_78()) return true; + final private boolean jj_3R_65() { + if (jj_3R_77()) return true; return false; } @@ -1546,8 +1550,8 @@ return false; } - final private boolean jj_3R_65() { - if (jj_3R_77()) return true; + final private boolean jj_3R_64() { + if (jj_3R_76()) return true; return false; } @@ -1556,11 +1560,6 @@ return false; } - final private boolean jj_3R_64() { - if (jj_3R_76()) return true; - return false; - } - final private boolean jj_3R_59() { Token xsp; xsp = jj_scanpos; @@ -1676,13 +1675,13 @@ return false; } - final private boolean jj_3R_82() { - if (jj_3R_80()) return true; + final private boolean jj_3R_49() { + if (jj_3R_59()) return true; return false; } - final private boolean jj_3R_49() { - if (jj_3R_59()) return true; + final private boolean jj_3R_82() { + if (jj_3R_80()) return true; return false; } @@ -1696,16 +1695,6 @@ return false; } - final private boolean jj_3R_75() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_82()) { - jj_scanpos = xsp; - if (jj_3R_83()) return true; - } - return false; - } - final private boolean jj_3R_19() { Token xsp; xsp = jj_scanpos; @@ -1722,6 +1711,16 @@ return false; } + final private boolean jj_3R_75() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_82()) { + jj_scanpos = xsp; + if (jj_3R_83()) return true; + } + return false; + } + final private boolean jj_3R_16() { if (jj_scan_token(TK_LABEL_AT)) return true; if (jj_3R_14()) return true; @@ -1835,11 +1834,6 @@ return false; } - final private boolean jj_3R_71() { - if (jj_3R_36()) return true; - return false; - } - final private boolean jj_3R_79() { Token xsp; xsp = jj_scanpos; @@ -1848,6 +1842,11 @@ return false; } + final private boolean jj_3R_71() { + if (jj_3R_36()) return true; + return false; + } + final private boolean jj_3R_70() { if (jj_3R_81()) return true; return false; @@ -2061,6 +2060,11 @@ return false; } + final private boolean jj_3R_24() { + if (jj_3R_39()) return true; + return false; + } + final private boolean jj_3R_14() { Token xsp; xsp = jj_scanpos; @@ -2082,11 +2086,6 @@ return false; } - final private boolean jj_3R_24() { - if (jj_3R_39()) return true; - return false; - } - final private boolean jj_3R_23() { if (jj_3R_38()) return true; return false; @@ -2097,11 +2096,6 @@ return false; } - final private boolean jj_3R_46() { - if (jj_scan_token(TK_FALSE)) return true; - return false; - } - final private boolean jj_3R_15() { Token xsp; while (true) { @@ -2124,6 +2118,11 @@ return false; } + final private boolean jj_3R_46() { + if (jj_scan_token(TK_FALSE)) return true; + return false; + } + final private boolean jj_3R_45() { if (jj_scan_token(TK_TRUE)) return true; return false; Modified: trunk/src/test/ASParserTest.java =================================================================== --- trunk/src/test/ASParserTest.java 2013-12-17 18:46:59 UTC (rev 1768) +++ trunk/src/test/ASParserTest.java 2013-12-20 17:59:14 UTC (rev 1769) @@ -251,7 +251,7 @@ Unifier un = new Unifier(); Term t = ASSyntax.parseTerm("{ +a(10) }"); assertTrue(t.isPlanBody()); - assertEquals("{ +a(10)[source(self)] }", t.toString()); + assertEquals("{ +a(10)[source(self)] }", t.toString()); // plan terms should not have default annotations t = ASSyntax.parseTerm("{ @label(a,b,10,test,long,label) +a(10) }"); assertTrue(t instanceof Plan); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2013-12-17 18:47:02
|
Revision: 1768 http://sourceforge.net/p/jason/svn/1768 Author: jomifred Date: 2013-12-17 18:46:59 +0000 (Tue, 17 Dec 2013) Log Message: ----------- fix a problem related to cartago compatibility Modified Paths: -------------- trunk/build.xml trunk/demos/distributed-jade/case2/myAllocator.java trunk/lib/jacamo.jar trunk/src/jason/bb/BeliefBase.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2013-12-11 14:43:03 UTC (rev 1767) +++ trunk/build.xml 2013-12-17 18:46:59 UTC (rev 1768) @@ -12,7 +12,7 @@ <property name="dist.properties" value="${basedir}/bin/dist.properties" /> <property name="version" value="1" /> - <property name="release" value="4.0" /> + <property name="release" value="4.0a" /> <property name="distDir" value="${env.HOME}/tmp/x/Jason-${version}.${release}" /> <property name="distFile" value="${env.HOME}/Jason-${version}.${release}" /> Modified: trunk/demos/distributed-jade/case2/myAllocator.java =================================================================== --- trunk/demos/distributed-jade/case2/myAllocator.java 2013-12-11 14:43:03 UTC (rev 1767) +++ trunk/demos/distributed-jade/case2/myAllocator.java 2013-12-17 18:46:59 UTC (rev 1768) @@ -40,7 +40,7 @@ int agsByContainer = nbAgs / containers.size(); System.out.println(agsByContainer+" agents will run in each container."); - + // create allocation int i=0; for (AgentParameters ap : project.getAgents()) { @@ -50,8 +50,8 @@ if (ap.qty > 1) { numberedAg += (cAg + 1); } - String c = containers.get( i % containers.size()); - System.out.println(" - agent "+numberedAg+" will run at "+c); + String c = containers.get( i % containers.size()); + System.out.println(" - agent "+numberedAg+" will run at "+c); allocation.put(numberedAg, c); i++; } Modified: trunk/lib/jacamo.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/bb/BeliefBase.java =================================================================== --- trunk/src/jason/bb/BeliefBase.java 2013-12-11 14:43:03 UTC (rev 1767) +++ trunk/src/jason/bb/BeliefBase.java 2013-12-17 18:46:59 UTC (rev 1768) @@ -47,10 +47,10 @@ public static final Term APercept = new Atom("percept"); /** represents the structure 'source(percept)' */ - public static final Pred TPercept = Pred.createSource(APercept); + public static final Term TPercept = Pred.createSource(APercept); /** represents the structure 'source(self)' */ - public static final Pred TSelf = Pred.createSource(ASelf); + public static final Term TSelf = Pred.createSource(ASelf); /** * Called before the MAS execution with the agent that uses this This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2013-12-11 14:43:07
|
Revision: 1767 http://sourceforge.net/p/jason/svn/1767 Author: jomifred Date: 2013-12-11 14:43:03 +0000 (Wed, 11 Dec 2013) Log Message: ----------- update junit.jar Modified Paths: -------------- trunk/lib/junit.jar Modified: trunk/lib/junit.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jom...@us...> - 2013-12-10 17:53:50
|
Revision: 1766 http://sourceforge.net/p/jason/svn/1766 Author: jomifred Date: 2013-12-10 17:53:48 +0000 (Tue, 10 Dec 2013) Log Message: ----------- fix a bug related to the generated scripts for Jade Modified Paths: -------------- trunk/bin/mas2j.sh trunk/demos/distributed-jade/case2/myAllocator.java trunk/lib/moise.jar trunk/src/jason/infra/jade/JadeMASLauncherAnt.java trunk/src/jason/jeditplugin/Config.java Modified: trunk/bin/mas2j.sh =================================================================== --- trunk/bin/mas2j.sh 2013-12-10 12:14:10 UTC (rev 1765) +++ trunk/bin/mas2j.sh 2013-12-10 17:53:48 UTC (rev 1766) @@ -19,7 +19,7 @@ cd $CURDIR -java -classpath bin/classes:$JASONDIR/lib/jason.jar:$JASONDIR/lib/saci.jar:$JASONDIR/lib/jade.jar:$JASONDIR/lib/c4jason.jar:$JASONDIR/lib/cartago.jar:$JASONDIR/lib/jacamo.jar:$CLASSPATH:. \ +java -classpath bin/classes:$JASONDIR/lib/jason.jar:$JASONDIR/lib/jade.jar:$JASONDIR/lib/c4jason.jar:$JASONDIR/lib/cartago.jar:$JASONDIR/lib/jacamo.jar:$CLASSPATH:. \ jason.mas2j.parser.mas2j $1 $2 #chmod u+x *.sh Modified: trunk/demos/distributed-jade/case2/myAllocator.java =================================================================== --- trunk/demos/distributed-jade/case2/myAllocator.java 2013-12-10 12:14:10 UTC (rev 1765) +++ trunk/demos/distributed-jade/case2/myAllocator.java 2013-12-10 17:53:48 UTC (rev 1766) @@ -39,9 +39,10 @@ } int agsByContainer = nbAgs / containers.size(); - + System.out.println(agsByContainer+" agents will run in each container."); + // create allocation - int i=1; + int i=0; for (AgentParameters ap : project.getAgents()) { String agName = ap.name; for (int cAg = 0; cAg < ap.qty; cAg++) { @@ -49,7 +50,9 @@ if (ap.qty > 1) { numberedAg += (cAg + 1); } - allocation.put(numberedAg, containers.get( i % agsByContainer)); + String c = containers.get( i % containers.size()); + System.out.println(" - agent "+numberedAg+" will run at "+c); + allocation.put(numberedAg, c); i++; } } Modified: trunk/lib/moise.jar =================================================================== (Binary files differ) Modified: trunk/src/jason/infra/jade/JadeMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2013-12-10 12:14:10 UTC (rev 1765) +++ trunk/src/jason/infra/jade/JadeMASLauncherAnt.java 2013-12-10 17:53:48 UTC (rev 1766) @@ -41,6 +41,7 @@ out.write(line+"\n"); } out.close(); + in.close(); } else { sFile.delete(); if (Config.get().getBoolean(Config.JADE_SNIFFER)) { @@ -160,7 +161,7 @@ String numberedAg = ap.getAgName(); if (ap.qty > 1) numberedAg += (cAg + 1); - if ( (container.equals("Main-Container") && ap.getHost() == null) || + if ( (container.equals("Main-Container") && ap.getHost() == null && allocator == null) || (ap.getHost() != null && ap.getHost().equals(container)) || (allocator != null && allocator.allocateAgent(numberedAg) != null && allocator.allocateAgent(numberedAg).equals(container))) { agents.append(sep+numberedAg+":"+JadeAgArch.class.getName()+"(j-project,"+project.getProjectFile().getName()+","+ap.getAgName()+")"); Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2013-12-10 12:14:10 UTC (rev 1765) +++ trunk/src/jason/jeditplugin/Config.java 2013-12-10 17:53:48 UTC (rev 1766) @@ -216,7 +216,7 @@ tryToFixJarFileConf(JASON_JAR, "jason.jar", 700000); tryToFixJarFileConf(JADE_JAR, "jade.jar", 2000000); tryToFixJarFileConf(MOISE_JAR, "moise.jar", 300000); - tryToFixJarFileConf(JACAMO_JAR, "jacamo.jar", 10000); + tryToFixJarFileConf(JACAMO_JAR, "jacamo.jar", 5000); // fix java home if (get(JAVA_HOME) == null || !checkJavaHomePath(getProperty(JAVA_HOME))) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |