Adicionado agente Aprendiz, Mediador e Dominio
authorpbarros <pbarros@EDEVELOPER>
Fri, 9 Mar 2012 21:12:34 +0000 (18:12 -0300)
committerpbarros <pbarros@EDEVELOPER>
Fri, 9 Mar 2012 21:12:34 +0000 (18:12 -0300)
src/java/org/ufcspa/simdecs/agent/AprendizAgent.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/agent/DominioAgent.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/agent/MediadorAgent.java [new file with mode: 0644]

diff --git a/src/java/org/ufcspa/simdecs/agent/AprendizAgent.java b/src/java/org/ufcspa/simdecs/agent/AprendizAgent.java
new file mode 100644 (file)
index 0000000..7030cb1
--- /dev/null
@@ -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=
+                                       "<br/> - " + myAgent.getLocalName() + " received: " + msg.getContent()+
+                                       "<br/> - " + 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 (file)
index 0000000..6d006d6
--- /dev/null
@@ -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=
+                                       "<br/> - " + myAgent.getLocalName() + " received: " + msg.getContent()+
+                                       "<br/> - " + 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 (file)
index 0000000..23dba9d
--- /dev/null
@@ -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=
+                                       "<br/> - " + myAgent.getLocalName() + " received: " + msg.getContent()+
+                                       "<br/> - " + 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) {}
+          }    
+}
+