本文整理汇总了Java中jade.domain.FIPAAgentManagement.DFAgentDescription.addServices方法的典型用法代码示例。如果您正苦于以下问题:Java DFAgentDescription.addServices方法的具体用法?Java DFAgentDescription.addServices怎么用?Java DFAgentDescription.addServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.domain.FIPAAgentManagement.DFAgentDescription
的用法示例。
在下文中一共展示了DFAgentDescription.addServices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAgentsByServiceType
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
/**
* Find and returns agents by a service type.
*
* @param serviceType the service type
* @return the dF agent description[]
*/
protected DFAgentDescription[] findAgentsByServiceType(String serviceType) {
DFAgentDescription[] dfAgentDescriptions = null;
try {
DFAgentDescription agentDescription = new DFAgentDescription();
ServiceDescription serviceDescription = new ServiceDescription();
serviceDescription.setType(serviceType);
agentDescription.addServices(serviceDescription);
dfAgentDescriptions = DFService.search(this.myAgent, agentDescription);
} catch (FIPAException fe) {
//fe.printStackTrace();
System.err.println("DFService: Error while requesting the DFService!");
}
return dfAgentDescriptions;
}
示例2: findAgentsByServiceType
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
/**
* Find and returns agents by a service type.
*
* @param serviceType the service type
* @return the dF agent description[]
*/
protected DFAgentDescription[] findAgentsByServiceType(String serviceType) {
DFAgentDescription[] dfAgentDescriptions = new DFAgentDescription[0];
try {
DFAgentDescription agentDescription = new DFAgentDescription();
ServiceDescription serviceDescription = new ServiceDescription();
serviceDescription.setType(serviceType);
agentDescription.addServices(serviceDescription);
dfAgentDescriptions = DFService.search(this, agentDescription);
} catch (FIPAException fe) {
//fe.printStackTrace();
System.err.println("DFService: Error while requesting the DFService!");
}
return dfAgentDescriptions;
}
示例3: registerAgInDF
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private void registerAgInDF() {
// DF register
DFAgentDescription dfa = new DFAgentDescription();
dfa.setName(getAID());
ServiceDescription vc = new ServiceDescription();
vc.setType("jason");
vc.setName(dfName);
dfa.addServices(vc);
try {
DFService.register(this,dfa);
} catch (FIPAException e) {
try {
DFService.deregister(this);
DFService.register(this,dfa);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Error registering agent in DF", e);
logger.log(Level.SEVERE, "Error unregistering agent in DF", ex);
}
}
}
示例4: getEnvironmentAg
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private AID getEnvironmentAg() {
// get the name of the environment
if (environmentAID == null) {
DFAgentDescription template = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("jason");
sd.setName(RunJadeMAS.environmentName);
template.addServices(sd);
try {
DFAgentDescription[] ans = DFService.search(jadeAg, template);
if (ans.length > 0) {
environmentAID = ans[0].getName();
return environmentAID;
}
} catch (Exception e) {
logger.log(Level.SEVERE,"Error getting environment from DF.",e);
}
}
return environmentAID;
}
示例5: setup
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
@Override
protected void setup() {
setRandomWallet();
addBehaviour(new BidRequestsServer());
// Register the auction-seller service in the yellow pages
DFAgentDescription dfd = new DFAgentDescription();
dfd.setName(getAID());
ServiceDescription sd = new ServiceDescription();
sd.setType("auction-bidder");
sd.setName("MultiAgentSystem-auctions");
dfd.addServices(sd);
try {
DFService.register(this, dfd);
} catch (FIPAException e) {
e.printStackTrace();
}
System.out.println(getAID().getName() + " ready to buy some stuff. My wallet is $" + wallet);
}
示例6: addAllAgsAsReceivers
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public void addAllAgsAsReceivers(ACLMessage m) throws Exception {
// get all agents' name
DFAgentDescription template = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("jason");
sd.setName(JadeAgArch.dfName);
template.addServices(sd);
DFAgentDescription[] ans = DFService.search(this, template);
for (int i=0; i<ans.length; i++) {
if (!ans[i].getName().equals(getAID())) {
m.addReceiver(ans[i].getName());
}
}
}
示例7: getEnvironmentAg
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private AID getEnvironmentAg() {
// get the name of the environment
if (!consultEnv) {
DFAgentDescription template = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("jason");
sd.setName(RunJadeMAS.environmentName);
template.addServices(sd);
try {
DFAgentDescription[] ans = DFService.search(jadeAg, template);
if (ans.length > 0) {
environmentAID = ans[0].getName();
}
} catch (Exception e) {
logger.log(Level.SEVERE,"Error getting environment from DF.",e);
}
consultEnv = true;
}
return environmentAID;
}
示例8: findRobots
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private boolean findRobots() {
boolean found = false;
DFAgentDescription agentDescriptionTemplate = new DFAgentDescription();
ServiceDescription serviceTransport = new ServiceDescription();
serviceTransport.setType("Raw");
SearchConstraints searchConstraints = new SearchConstraints();
searchConstraints.setSearchId("Raw");
agentDescriptionTemplate.addServices(serviceTransport);
try {
DFAgentDescription[] foundRobots = DFService.search(this, agentDescriptionTemplate);
_broadcastAddr = new AID[foundRobots.length];
for (int i = 0; i < foundRobots.length; i++) {
found = true;
_broadcastAddr[i] = foundRobots[i].getName();
}
} catch (FIPAException exception) {
exception.printStackTrace();
}
return found;
}
示例9: registerDFRaw
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private void registerDFRaw() {
String agentServiceGroup = new String("Raw");
String agentServiceName = new String("Raw");
ServiceDescription serviceDescription = new ServiceDescription();
serviceDescription.setName(agentServiceGroup);
serviceDescription.setType(agentServiceName);
DFAgentDescription agentDescription = new DFAgentDescription();
agentDescription.setName(getAID());
agentDescription.addServices(serviceDescription);
try {
DFService.register(this, agentDescription);
} catch (FIPAException exception) {
exception.printStackTrace();
}
}
示例10: registerNeedWorker
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
private void registerNeedWorker() {
DFAgentDescription dfServiceDescription = new DFAgentDescription();
if (this.floor instanceof CleaningFloor) {
ServiceDescription needClean = new ServiceDescription();
needClean.setName("needClean");
needClean.setType("needClean");
dfServiceDescription.addServices(needClean);
} else {
ServiceDescription needPaint = new ServiceDescription();
needPaint.setName("needPaint");
needPaint.setType("needPaint");
dfServiceDescription.addServices(needPaint);
}
try {
DFService.register(this.floorAgent, dfServiceDescription);
} catch (FIPAException e) {
e.printStackTrace();
}
}
示例11: register
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public static void register(Agent a, String service, Codec codec, String protocol, Ontology ontology) throws FIPAException {
DFAgentDescription dfad = new DFAgentDescription();
dfad.setName(a.getAID());
dfad.addLanguages(codec.getName());
dfad.addProtocols(protocol);
ServiceDescription sd = new ServiceDescription();
sd.setName(service + "-" + a.getLocalName());
sd.setType(service);
sd.addOntologies(ontology.getName());
sd.addLanguages(codec.getName());
sd.addProtocols(protocol);
dfad.addServices(sd);
DFService.register(a, dfad);
}
示例12: findAllByService
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public static ArrayList<AID> findAllByService(Agent a, String serviceName) throws FIPAException {
DFAgentDescription adTemplate = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType(serviceName);
adTemplate.addServices(sd);
DFAgentDescription[] dfAgentDescriptions = DFService.search(a, adTemplate);
if (dfAgentDescriptions.length <= 0) {
throw new FIPAException("Could not find proper service");
}
ArrayList<AID> aids = new ArrayList<AID>();
for (DFAgentDescription dfAgentDescription : dfAgentDescriptions) {
aids.add(dfAgentDescription.getName());
}
return aids;
}
示例13: action
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public void action() {
sm.Log("RegisterInDFBehaviour - start");
ServiceDescription sd = new ServiceDescription();
sd.setType(getType());
sd.setName(this.myAgent.getName());
sd.setOwnership(getOwner());
DFAgentDescription dfd = new DFAgentDescription();
dfd.setName(this.myAgent.getAID());
dfd.addServices(sd);
try {
DFAgentDescription[] dfds = DFService.search(this.myAgent, dfd);
if (dfds.length > 0) {
DFService.deregister(this.myAgent, dfd);
}
DFService.register(this.myAgent, dfd);
sm.Log(this.myAgent.getLocalName() + " is ready.");
} catch (Exception ex) {
sm.Log("Failed registering with DF! Shutting down...");
ex.printStackTrace();
this.myAgent.doDelete();
}
sm.Log("RegisterInDFBehaviour - end");
}
示例14: getServerName
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public AID getServerName() {
if (server_name != null) {
return server_name;
}
DFAgentDescription template=new DFAgentDescription();
ServiceDescription sd=new ServiceDescription();
sd.setType("Organisation");
sd.setName("Multiplay");
template.addServices(sd);
try{
DFAgentDescription[] result=DFService.search(this, template);
if(result.length>0){
server_name = result[0].getName();
}
}catch(FIPAException fe){
fe.printStackTrace();
}
return server_name;
}
示例15: getNoteAgentName
import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入方法依赖的package包/类
public AID getNoteAgentName() {
if (note_agent_name != null) {
return note_agent_name;
}
DFAgentDescription template=new DFAgentDescription();
ServiceDescription sd=new ServiceDescription();
sd.setType("Organisation");
sd.setName("MoveToNote");
template.addServices(sd);
try{
DFAgentDescription[] result=DFService.search(this, template);
if(result.length>0){
note_agent_name = result[0].getName();
}
}catch(FIPAException fe){
fe.printStackTrace();
}
return note_agent_name;
}