Magentix2
2.1.1
|
Public Member Functions | |
void | run () |
String | getAgName () |
void | setPerception (List< Literal > perc) |
List< Literal > | perceive () |
void | act (ActionExec action, List< ActionExec > feedback) |
boolean | canSleep () |
boolean | isRunning () |
void | sleep () |
void | sendMsg (jason.asSemantics.Message m) throws Exception |
void | checkMail () |
void | broadcast (jason.asSemantics.Message m) throws Exception |
void | stopAg () |
ConvJasonAgent | getJasonAgent () |
Protected Member Functions | |
void | init (String filename, CAgent agent, BeliefBase bb, String[] bbParameters) |
Object | translateContentToJason (ACLMessage m) |
void | addMessage (ACLMessage msg) |
Protected Attributes | |
boolean | running = true |
Map< String, String > | conversationIds = new HashMap<String,String>() |
This class represents the architecture of the Jason agent for it to keep conversations by using the Conversations Factory
Definition at line 39 of file ConvMagentixAgArch.java.
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.act | ( | ActionExec | action, |
List< ActionExec > | feedback | ||
) |
Definition at line 123 of file ConvMagentixAgArch.java.
{ getTS().getLogger().info("Agent " + action.getActionTerm() + " is doing: " + action.getActionTerm()); // return confirming the action execution was OK action.setResult(true); feedback.add(action); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.addMessage | ( | ACLMessage | msg | ) | [protected] |
Adds a message to the message list
msg |
Definition at line 318 of file ConvMagentixAgArch.java.
{ this.messageList.add(msg); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.broadcast | ( | jason.asSemantics.Message | m | ) | throws Exception |
Definition at line 232 of file ConvMagentixAgArch.java.
{ }
Definition at line 133 of file ConvMagentixAgArch.java.
{ return true; }
Definition at line 167 of file ConvMagentixAgArch.java.
{ ACLMessage m; do{ m = messageList.poll(); if (m != null){ String ilForce = aclToKqml(m.getPerformativeInt()); String sender = m.getSender().name; String receiver = m.getReceiver().name; String replyWith = m.getReplyWith(); String irt = m.getInReplyTo(); // also remembers conversation ID if (replyWith != null && replyWith.length() > 0) { if (m.getConversationId() != null) { conversationIds.put(replyWith, m.getConversationId()); } } else { replyWith = "noid"; } Object propCont = translateContentToJason(m); if (propCont != null) { jason.asSemantics.Message im = new jason.asSemantics.Message(ilForce, sender, receiver, propCont, replyWith); if (irt != null) { im.setInReplyTo(irt); } this.getTS().getC().getMailBox().offer(im); // Bexy: Substituting add by offer } } } while(m != null); }
Definition at line 91 of file ConvMagentixAgArch.java.
Definition at line 329 of file ConvMagentixAgArch.java.
{
return jasonAgent;
}
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.init | ( | String | filename, |
CAgent | agent, | ||
BeliefBase | bb, | ||
String[] | bbParameters | ||
) | [protected] |
Starts the architecture
filename | File with the AgentSepak code |
agent | Agent with this architecture |
Definition at line 52 of file ConvMagentixAgArch.java.
{ try { this.jasonAgent = (ConvJasonAgent) agent; Agent ag = new Agent(); Settings set = new Settings();//Bexy set.setVerbose(0);//Bexy new TransitionSystem(ag, new Circumstance(), new Settings(), this); if (bb!=null) { ag.setBB(bb); } ag.initAg(filename); ag.getBB().init(ag, bbParameters); } catch (Exception e) { logger.log(Level.SEVERE, "Init error", e); } }
Definition at line 138 of file ConvMagentixAgArch.java.
{ return running; }
Definition at line 109 of file ConvMagentixAgArch.java.
{ //List<Literal> l = new ArrayList<Literal>(); List<Literal> tmpPerc; if ((Perceptions!=null)&&(Perceptions.size()>0)){ tmpPerc = new ArrayList<Literal>(Perceptions);} else { tmpPerc = new ArrayList<Literal>(); } Perceptions.clear(); return new ArrayList<Literal>(tmpPerc); }
Runs the reasoning cycle
Definition at line 74 of file ConvMagentixAgArch.java.
{ RunCentralisedMAS.setupLogger(); try { while (isRunning()) { // Ricard: calls the Jason engine to perform one reasoning cycle logger.fine("Reasoning...."); // Ricard: parche para arreglar la sincronizacion, buscar mejor solucion y porque occure esto if(this.jasonAgent.getMutexHoldCount() > 0) this.jasonAgent.unlock(); getTS().reasoningCycle(); } } catch (Exception e) { logger.log(Level.SEVERE, "Run error", e); } }
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.sendMsg | ( | jason.asSemantics.Message | m | ) | throws Exception |
Definition at line 153 of file ConvMagentixAgArch.java.
{ ACLMessage acl = jasonToACL(m); acl.addReceiver(new AgentID(m.getReceiver())); if (m.getInReplyTo() != null) { String convid = conversationIds.get(m.getInReplyTo()); if (convid != null) { acl.setConversationId(convid); } } acl.getHeaders().put("jason", "true"); this.jasonAgent.send(acl); }
void es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.setPerception | ( | List< Literal > | perc | ) |
Definition at line 98 of file ConvMagentixAgArch.java.
{
for (Literal p:perc){
Perceptions.add(p);
}
}
Definition at line 144 of file ConvMagentixAgArch.java.
{ try { Thread.sleep(100); } catch (InterruptedException e) {} }
Definition at line 322 of file ConvMagentixAgArch.java.
{ running = false; }
Object es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.translateContentToJason | ( | ACLMessage | m | ) | [protected] |
returns the content of the message m and implements some pro-processing of the content, if necessary
m | Message to translate |
Definition at line 204 of file ConvMagentixAgArch.java.
{ Object propCont = null; try { propCont = m.getContentObject(); if (propCont instanceof String) { // try to parse as term try { propCont = ASSyntax.parseTerm((String)propCont); } catch (Exception e) { // no problem } } } catch (Exception e) { // no problem try another thing } if (propCont == null) { // still null // try to parse as term try { propCont = ASSyntax.parseTerm(m.getContent()); } catch (Exception e) { // not AS messages are treated as string propCont = new StringTermImpl(m.getContent()); } } return propCont; }
Map<String,String> es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.conversationIds = new HashMap<String,String>() [protected] |
Definition at line 150 of file ConvMagentixAgArch.java.
boolean es.upv.dsic.gti_ia.jason.conversationsFactory.ConvMagentixAgArch.running = true [protected] |
Definition at line 44 of file ConvMagentixAgArch.java.