当前位置: 首页>>代码示例>>Java>>正文


Java DFAgentDescription类代码示例

本文整理汇总了Java中jade.domain.FIPAAgentManagement.DFAgentDescription的典型用法代码示例。如果您正苦于以下问题:Java DFAgentDescription类的具体用法?Java DFAgentDescription怎么用?Java DFAgentDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DFAgentDescription类属于jade.domain.FIPAAgentManagement包,在下文中一共展示了DFAgentDescription类的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;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:SimulationServiceBehaviour.java

示例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;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:SimulationAgent.java

示例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);
        }
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:21,代码来源:JadeAgArch.java

示例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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:21,代码来源:JasonBridgeArch.java

示例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);
}
 
开发者ID:ohvitorino,项目名称:auctions,代码行数:23,代码来源:BidderAgent.java

示例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());
        }
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:15,代码来源:JadeAg.java

示例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;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:21,代码来源:JasonBridgeArch.java

示例8: action

import jade.domain.FIPAAgentManagement.DFAgentDescription; //导入依赖的package包/类
@Override
public void action() {
	DFAgentDescription[] cleanServices = findCleanServices();
	if (cleanServices != null) {
		if (!_controller.doWork()) {
			// failure
		} else {
			if(this.serviceName.equals("needClean")){
				_communicator.requestCleanBlock();
			} else {
				_communicator.requestPaintBlock();;
			}
			ACLMessage reply = _communicator.receiveReply();
			if (reply.getPerformative() == ACLMessage.INFORM) {
				System.out.println(this.myAgent.getAID().getLocalName() + ": performed working successfully");
			} else {
				System.out.println("working failed");
			}
		}
	}
	this.myAgent.doWait(1000);
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:23,代码来源:WorkerBehaviour.java

示例9: 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;
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:23,代码来源:RobotAgent.java

示例10: 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();
		}
	}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:18,代码来源:RobotAgent.java

示例11: 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();
	}
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:20,代码来源:FloorCommunicator.java

示例12: 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);
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:17,代码来源:DFServiceHelper.java

示例13: 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;
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:17,代码来源:DFServiceHelper.java

示例14: 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");
}
 
开发者ID:JordiCorbilla,项目名称:DDM,代码行数:24,代码来源:RegisterInDFBehaviour.java

示例15: 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;
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:20,代码来源:UserAgent.java


注:本文中的jade.domain.FIPAAgentManagement.DFAgentDescription类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。