-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyAgentMg.java
115 lines (94 loc) · 3.38 KB
/
MyAgentMg.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.awt.*;
import javax.swing.*;
import jade.core.Agent;
import jade.core.AID;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPANames;
import jade.domain.FIPAAgentManagement.*;
import jade.lang.acl.*;
import java.util.*;
import jade.core.behaviours.*;
public class MyAgentMg extends Agent{
AID[] liste;
DFAgentDescription[] results;
private Vector sellerAgents = new Vector();
protected void setup()
{
String NomAgent;
String serviceName="Gestionnaire du système workflow";
DFAgentDescription dfd = new DFAgentDescription();
dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setName(serviceName);
sd.addLanguages("XPDL");
sd.setType("Compagnie d'assurance");
sd.addProtocols("Contract-Net");
sd.addOntologies("Ontologie Assurance");
sd.addProperties(new Property("Paye", "Algérie"));
dfd.addServices(sd);
try {
DFService.register(this, dfd );
}catch (FIPAException fe) {}
Object[] args = getArguments();
if (args != null && args.length > 0) {
for (int i = 0; i < args.length; ++i) {
AID seller = new AID((String) args[i], AID.ISLOCALNAME);
sellerAgents.addElement(seller);
}
int taille;
taille=sellerAgents.size();
System.out.println(taille);
// ------------Interface Agent
NomAgent=getLocalName();
//Create labels and text fields
JLabel lastName1 = new JLabel("Mon Nom :",JLabel.RIGHT );
JLabel lastName = new JLabel(NomAgent,JLabel.RIGHT);
JLabel middleName = new JLabel("Service fourni : ", JLabel.RIGHT);
JLabel middleName2 = new JLabel("Gestionnaire du système workflow", JLabel.RIGHT);
//Layout and Display
JPanel p = new JPanel();
p.setLayout(new GridLayout(3,2,5,5));
p.add(lastName1);
p.add(lastName);
p.add(middleName);
p.add(middleName2);
//p.add(middleField);
JFrame f = new JFrame();
f.setSize(300,300);
//f.addWindowListener(new BasicWindowMonitor());
f.setContentPane(p);
f.pack();
f.setVisible(true);
//------------------------------------------------//
/* try {
results = DFService.search(this, dfd);
if (results.length > 0) {
liste = new AID[results.length];
// System.out.println("Agent "+getLocalName()+" found the following"+ serviceType+" services:");
for (int i = 0; i < results.length; ++i) {
liste[i]=results[i].getName();
System.out.println(liste[i].getName() );
DFAgentDescription dfd1 = results[i];
AID provider = dfd1.getName();
}
}
}// end try
catch (FIPAException fe) {
fe.printStackTrace();}
*/
AppelOffre Appel= new AppelOffre();
addBehaviour(Appel);
}//end Setup
}
private class AppelOffre extends OneShotBehaviour{
public void action() {
ACLMessage cfp = new ACLMessage(ACLMessage.CFP);
for(int i = 0; i < liste.length; ++i){
cfp.addReceiver(liste[i]);
} // end for
cfp.setLanguage("<tache> operation</tache>");
myAgent.send(cfp);
}
}
}