From: pbarros Date: Fri, 9 Mar 2012 21:12:34 +0000 (-0300) Subject: Adicionado agente Aprendiz, Mediador e Dominio X-Git-Url: http://200.18.67.61/gitweb/?a=commitdiff_plain;h=c70f5ee157d248f37b6de5f32a81fe7c0a2e0dfb;p=simdecs2.git Adicionado agente Aprendiz, Mediador e Dominio --- diff --git a/src/java/org/ufcspa/simdecs/agent/AprendizAgent.java b/src/java/org/ufcspa/simdecs/agent/AprendizAgent.java new file mode 100644 index 0000000..7030cb1 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/agent/AprendizAgent.java @@ -0,0 +1,53 @@ +package org.ufcspa.simdecs.agent; +/***************************************************************** + +Agent which answers all messages with a "Pong" + +*****************************************************************/ + + +import jade.core.Agent; +import jade.core.behaviours.*; +import jade.lang.acl.*; + +import jade.domain.DFService; +import jade.domain.FIPAAgentManagement.*; +import jade.domain.FIPAException; + +public class AprendizAgent extends Agent +{ + + protected void setup() + { + + // pong behaviour + addBehaviour(new CyclicBehaviour(this) + { + public void action() + { + ACLMessage msg = receive(); + String content= ""; + if (msg!=null) { + content= + "
- " + myAgent.getLocalName() + " received: " + msg.getContent()+ + "
- " + myAgent.getLocalName() + " sent: " + "Pong"; + + ACLMessage reply = msg.createReply(); + reply.setPerformative( ACLMessage.INFORM ); + reply.setContent(content); + send(reply); + System.out.print(content); + } + else block(); + } + }); + + } + + protected void takeDown() + { + try { DFService.deregister(this); } + catch (Exception e) {} + } +} + diff --git a/src/java/org/ufcspa/simdecs/agent/DominioAgent.java b/src/java/org/ufcspa/simdecs/agent/DominioAgent.java new file mode 100644 index 0000000..6d006d6 --- /dev/null +++ b/src/java/org/ufcspa/simdecs/agent/DominioAgent.java @@ -0,0 +1,53 @@ +package org.ufcspa.simdecs.agent; +/***************************************************************** + +Agent which answers all messages with a "Pong" + +*****************************************************************/ + + +import jade.core.Agent; +import jade.core.behaviours.*; +import jade.lang.acl.*; + +import jade.domain.DFService; +import jade.domain.FIPAAgentManagement.*; +import jade.domain.FIPAException; + +public class DominioAgent extends Agent +{ + + protected void setup() + { + + // pong behaviour + addBehaviour(new CyclicBehaviour(this) + { + public void action() + { + ACLMessage msg = receive(); + String content= ""; + if (msg!=null) { + content= + "
- " + myAgent.getLocalName() + " received: " + msg.getContent()+ + "
- " + myAgent.getLocalName() + " sent: " + "Pong"; + + ACLMessage reply = msg.createReply(); + reply.setPerformative( ACLMessage.INFORM ); + reply.setContent(content); + send(reply); + System.out.print(content); + } + else block(); + } + }); + + } + + protected void takeDown() + { + try { DFService.deregister(this); } + catch (Exception e) {} + } +} + diff --git a/src/java/org/ufcspa/simdecs/agent/MediadorAgent.java b/src/java/org/ufcspa/simdecs/agent/MediadorAgent.java new file mode 100644 index 0000000..23dba9d --- /dev/null +++ b/src/java/org/ufcspa/simdecs/agent/MediadorAgent.java @@ -0,0 +1,53 @@ +package org.ufcspa.simdecs.agent; +/***************************************************************** + +Agent which answers all messages with a "Pong" + +*****************************************************************/ + + +import jade.core.Agent; +import jade.core.behaviours.*; +import jade.lang.acl.*; + +import jade.domain.DFService; +import jade.domain.FIPAAgentManagement.*; +import jade.domain.FIPAException; + +public class MediadorAgent extends Agent +{ + + protected void setup() + { + + // pong behaviour + addBehaviour(new CyclicBehaviour(this) + { + public void action() + { + ACLMessage msg = receive(); + String content= ""; + if (msg!=null) { + content= + "
- " + myAgent.getLocalName() + " received: " + msg.getContent()+ + "
- " + myAgent.getLocalName() + " sent: " + "Pong"; + + ACLMessage reply = msg.createReply(); + reply.setPerformative( ACLMessage.INFORM ); + reply.setContent(content); + send(reply); + System.out.print(content); + } + else block(); + } + }); + + } + + protected void takeDown() + { + try { DFService.deregister(this); } + catch (Exception e) {} + } +} +