• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Agent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Agent类属于jade.core包,在下文中一共展示了Agent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addAgent

import jade.core.Agent; //导入依赖的package包/类
/**
 * Adds an agent to the start list corresponding to the current network component .
 * 
 * @param networkComponent the NetworkComponent
 */
public void addAgent(NetworkComponent networkComponent) {

	if (networkComponent == null) {
		return;
	}
	Class<? extends Agent> agentClass = this.getAgentClass(networkComponent.getAgentClassName());
	if (agentClass != null) {

		int newPosNo = this.getEmptyPosition4Agents2Start();
		// --- Agent class found. Create new list element ---------
		AgentClassElement4SimStart ace4s = new AgentClassElement4SimStart(agentClass, SimulationSetup.AGENT_LIST_EnvironmentConfiguration);
		ace4s.setStartAsName(networkComponent.getId());
		ace4s.setPostionNo(newPosNo);
		// --- Add the new list element to the list ---------------
		this.getAgents2Start().add(newPosNo - 1, ace4s);
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:GraphEnvironmentController.java


示例2: getAgentClass

import jade.core.Agent; //导入依赖的package包/类
/**
 * Returns the agent class.
 * 
 * @param agentReference the agent reference
 * @return the agent class
 */
@SuppressWarnings("unchecked")
private Class<? extends Agent> getAgentClass(String agentReference) {

	if (agentReference == null || agentReference.equals("")) {
		return null;
	}

	Class<? extends Agent> agentClass = null;
	try {
		agentClass = (Class<? extends Agent>) ClassLoadServiceUtility.forName(agentReference);
	} catch (ClassNotFoundException ex) {
		System.err.println("Could not find agent class '" + agentReference + "'");
	}
	return agentClass;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:22,代码来源:GraphEnvironmentController.java


示例3: startAgent

import jade.core.Agent; //导入依赖的package包/类
/**
 * Method to start a new agent.
 *
 * @param nickName the nick name
 * @param agentClassName the agent class name
 * @param args the start arguments as Object array
 * @param toLocation the location, where the agent should start
 * @return true, if successful
 */
protected boolean startAgent(String nickName, String agentClassName, Object[] args, Location toLocation ) {
	
	if (agentClassName==null | agentClassName.equalsIgnoreCase("") | agentClassName.equalsIgnoreCase(Language.translate("Keine")) ) {
		System.err.println(Language.translate("Agent '" + nickName + "': " + Language.translate("Keine Klasse definiert") + "!"));
	} else {
		// --- Initialize the agent-class -------------
		try {
			Class<? extends Agent> agentClass = ClassLoadServiceUtility.getAgentClass(agentClassName);
			return this.startAgent(nickName, agentClass, args, toLocation);
			
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	return false;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:26,代码来源:BaseLoadBalancing.java


示例4: SingleAgentMonitor

import jade.core.Agent; //导入依赖的package包/类
/**
 * Instantiates a new agent monitor.
 *
 * @param agent the agent to monitor
 * @param monitoringMeasureType the actual MonitoringMeasureType
 * @param runnable the runnable
 */
public SingleAgentMonitor(Agent agent, MonitoringMeasureType monitoringMeasureType, Runnable runnable) {
	if (agent==null) {
		throw new IllegalArgumentException("No agent was specified for the monitoring task.");
	}
	if (monitoringMeasureType==null) {
		throw new IllegalArgumentException("No measure were specified in case of a thread failure.");
	}
	if (monitoringMeasureType==MonitoringMeasureType.CUSTOM_MEASURE && runnable==null) {
		throw new IllegalArgumentException("No runnable was defined for the custom measure.");
	}
	
	this.agentName = agent.getLocalName();
	this.agentClass = agent.getClass().getName();
	this.agentStartArguments = agent.getArguments();
	this.containerController = agent.getContainerController();
	
	this.monitoringMeasureType = monitoringMeasureType;
	this.measure = runnable;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:27,代码来源:SingleAgentMonitor.java


示例5: getStartAndStaticLoadBalancingClass

import jade.core.Agent; //导入依赖的package包/类
/**
 * This method will initiate the one shot behaviour of the type {@link StaticLoadBalancingBase}
 * in order to start the agency.
 *
 * @return the start and static load balancing instance
 */
private StaticLoadBalancingBase getStartAndStaticLoadBalancingClass(Agent myAgent) {
	
	// --- Get the current distribution setup ---------
	DistributionSetup currDisSetup = Application.getProjectFocused().getDistributionSetup();
	if (currDisSetup.isDoStaticLoadBalancing()==true) {

		try {
			return ClassLoadServiceUtility.getStaticLoadBalancing(currDisSetup.getStaticLoadBalancingClass(), myAgent);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		
	} else {
		return new StaticLoadBalancing(this);
	}
	return null;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:24,代码来源:LoadExecutionAgent.java


示例6: GameLoadBehaviour

import jade.core.Agent; //导入依赖的package包/类
public GameLoadBehaviour(Agent agent, String filename) throws FileNotFoundException
{
    super(agent);
    
    // Loads the board
    ((GameAgent) agent).setBoard(loadBoard(filename));
    
    if (Constant.DEBUG)
    {
        System.out.println("Board model initialized...\nInitial board:");
        board.print();
    }
    
    // Fetches the container manager instance
    containerManager = ContainerManager.getInstance();
}
 
开发者ID:wguilen,项目名称:pacman-mas,代码行数:17,代码来源:GameLoadBehaviour.java


示例7: register

import jade.core.Agent; //导入依赖的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


示例8: findAllByService

import jade.core.Agent; //导入依赖的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


示例9: agentTest

import jade.core.Agent; //导入依赖的package包/类
@Test
public void agentTest() throws Exception
{
	final AgentContainer container = getContainer();
	final String agName = "MyTestAgent";
	final MySemanticAgent agObject = new MySemanticAgent();
	LOG.trace("Adding new agent: " + agName + "...");
	container.acceptNewAgent(agName, agObject);

	while (agObject.getAgentState().getValue() != Agent.AP_DELETED)
	{
		LOG.trace("Waiting for " + agName + " (state: "
				+ agObject.getAgentState() + ") to be killed via GUI...");
		try
		{
			Thread.sleep(1000);
		} catch (final InterruptedException ignore)
		{
			//
		}
	}
	
	container.kill();
}
 
开发者ID:krevelen,项目名称:coala,代码行数:25,代码来源:TestSemanticAgent.java


示例10: registerAgent

import jade.core.Agent; //导入依赖的package包/类
/**
 * Register the agent in the platform
 * 
 * @param agent_name
 *          The name of the agent to be registered
 * @param agent
 *          The agent to register.
 * @throws FIPAException 
 */
public static void registerAgent(Agent agent, String serviceName, String serviceType) throws FIPAException{
    DFAgentDescription dfd = new DFAgentDescription();
    ServiceDescription sd = new ServiceDescription();
    
    sd.setType(serviceType);
    sd.setName(serviceName);
    
    //NOTE El serviceType es un string que define el tipo de servicio publicado en el DF por el Agente X. 
    //     He escogido crear nombres en clave en jade.common.Definitions para este campo. 
    //NOTE El serviceName es el nombre efectivo del servicio. 
    //     Esto es lo que el usuario va a definir en MockConfiguration.DFNameService y no el tipo como estaba puesto. 
    //        sd.setType(agentType);
    //        sd.setName(agent.getLocalName());
    
    //Add services??
    
    // Sets the agent description
    dfd.setName(agent.getAID());
    dfd.addServices(sd);
    
    // Register the agent
    DFService.register(agent, dfd);
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:33,代码来源:AgentRegistration.java


示例11: sendMessageToAgents

import jade.core.Agent; //导入依赖的package包/类
@Override
public void sendMessageToAgents(String[] agent_name, String msgtype,
        Object message_content, Connector connector) {
    Agent messenger = (Agent) connector.getMessageService();
    JadeAgentIntrospector introspector = (JadeAgentIntrospector) PlatformSelector.getAgentIntrospector("jade");

    ACLMessage msg = null;
    if(message_content instanceof ACLMessage) {
        msg = (ACLMessage) message_content;
    } else if (message_content instanceof String) {
        msg = new ACLMessage(ACLMessage.getInteger(msgtype)); 
        msg.setContent( (String) message_content);            
    } else {
        connector.getLogger().warning("Incorrect message_content value. It should be a ACLMessage or a String.");
    }

    for (String name : agent_name) {
        Agent agent = introspector.getAgent(name);
        AID aid = agent.getAID();
        msg.addReceiver(aid);
        connector.getLogger().finer("Receiver added to the message...");
    }
    messenger.send(msg);
    connector.getLogger().finer("Message sent...");
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:26,代码来源:JadeMessenger.java


示例12: setup

import jade.core.Agent; //导入依赖的package包/类
public void setup() {
	this.myIntrospector = JadeAgentIntrospector.getMyInstance((Agent) this);
	LogActivator.logToFile(logger, this.getName(), Level.ALL);
	// Register the service
	try {
		DFAgentDescription dfd = new DFAgentDescription();
		ServiceDescription sd = new ServiceDescription();
        
        sd.setType("server");
        sd.setName("report-service");
        // Sets the agent description
        dfd.setName(this.getAID());
        dfd.addServices(sd);
        
        // Register the agent
        DFService.register(this, dfd);
		
	} catch (Exception e) {
		logger.severe("Exception registering agent in DF. Agent: " + this.getName());
	}

	MessageTemplate t = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
	addBehaviour(new ReportServer(this,t));
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:25,代码来源:ReporterAgent.java


示例13: setup

import jade.core.Agent; //导入依赖的package包/类
public void setup() {
	this.myIntrospector = JadeAgentIntrospector.getMyInstance((Agent) this);
	LogActivator.logToFile(logger, this.getName(), Level.ALL);
	// Register the service
	try {
		DFAgentDescription dfd = new DFAgentDescription();
		ServiceDescription sd = new ServiceDescription();
        
        sd.setType("server");
        sd.setName("helpdesk-service");
        // Sets the agent description
        dfd.setName(this.getAID());
        dfd.addServices(sd);
        
        // Register the agent
        DFService.register(this, dfd);
		
	} catch (Exception e) {
		logger.severe("Exception registering agent in DF. Agent: " + this.getName());
	}

	MessageTemplate t = MessageTemplate.MatchPerformative(ACLMessage.REQUEST);
	addBehaviour(new HelpDeskServer(this,t));
	
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:26,代码来源:HelpDeskAgent.java


示例14: getMyEnvironmentType

import jade.core.Agent; //导入依赖的package包/类
/**
 * Returns my personal EnvironmentType.
 * @return the my environment type
 */
private EnvironmentType getMyEnvironmentType() {
	
	String key = "Squared";
	String displayName = "Discrete squares environment";
	String displayNameLanguage = Language.EN;
	Class<? extends EnvironmentController> controllerClass = SquaredEnvironmentController.class;
	Class<? extends Agent> agentClass = DisplayAgent.class;
	
	EnvironmentType myEnvType = new EnvironmentType(key, displayName, displayNameLanguage, controllerClass, agentClass);
	return myEnvType;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:16,代码来源:GameOfLifePlugIn.java


示例15: getAgentClassesCellEditor

import jade.core.Agent; //导入依赖的package包/类
/**
 * Returns the ClassSelectionDialog cell editor for Agent classes.
 * @return cell editor for the class selection
 */
private TableCellEditor4ClassSelector getAgentClassesCellEditor(){
	if(agentClassesCellEditor == null){
		agentClassesCellEditor = new TableCellEditor4ClassSelector(Application.getMainWindow(), Agent.class, "", "", Language.translate("Agenten"), true);
	}
	return agentClassesCellEditor;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:11,代码来源:ComponentTypeDialog.java


示例16: startVisualizationAgent

import jade.core.Agent; //导入依赖的package包/类
/**
 * This method will start the agent that will show the visualisation of the current environment model.
 * In case of an headless operation of Agent.GUI, this method will do nothing.
 * 
 * @see Application#isOperatingHeadless()
 */
protected void startVisualizationAgent() {
	
	// --- Visualisation is only needed in case of a none headless operation
	if (Application.isOperatingHeadless()==true) return;
	
	EnvironmentController envController = currProject.getEnvironmentController();
	if (envController!=null) {
		
		EnvironmentType envType = currProject.getEnvironmentModelType();
		String envTypeInternalKey = envType.getInternalKey();
		
		// ----------------------------------------------------------------
		// --- Start visualisation, if an visualised environment is used --
		// ----------------------------------------------------------------
		if (envTypeInternalKey.equalsIgnoreCase("none")==false) {

			// --- Get the Agent which has to be started for ---
			Class<? extends Agent> displayAgentClass = envType.getDisplayAgentClass();
			
			Object[] startArg = new Object[3];
			startArg[0] = currProject.getVisualisationTab4SetupExecution();
			startArg[1] = envController;
			this.startAgent("DisplayAgent", displayAgentClass, startArg);
			
			// --- Set the focus on Visualisation-Tab ---------------------
			currProject.getProjectEditorWindow().setFocus2Tab(Language.translate(ProjectWindowTab.TAB_4_RUNTIME_VISUALISATION));
		}
		// ----------------------------------------------------------------
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:37,代码来源:StaticLoadBalancingBase.java


示例17: BaseLoadBalancing

import jade.core.Agent; //导入依赖的package包/类
/**
 * Instantiates a new base load balancing.
 */
public BaseLoadBalancing(Agent agent) {
	super(agent);
	this.currProject = Application.getProjectFocused();		
	if (this.currProject!=null) {
		this.currSimSetup = this.currProject.getSimulationSetups().getCurrSimSetup();
		this.currDisSetup = this.currProject.getDistributionSetup();
	}
	this.setLoadHelper();
	this.setSimulationHelper();
	this.setThresholdLevels();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:15,代码来源:BaseLoadBalancing.java


示例18: JadeRemoteStart

import jade.core.Agent; //导入依赖的package包/类
/**
 * Instantiates a new jade remote start.
 *
 * @param agent the current agent that uses this class
 * @param remoteContainerConfig the RemoteContainerConfig
 */
public JadeRemoteStart(Agent agent, RemoteContainerConfig remoteContainerConfig) {
	
	this.myAgent = agent;
	this.reCoCo = remoteContainerConfig;
	
	if (this.debug) {
		System.out.println("Class '" + this.getClass().getName() + "' in debug modue ...");
	}
	
	// --- Configure JVM arguments ------------------------------
	if (this.reCoCo.getJvmMemAllocInitial()==null && this.reCoCo.getJvmMemAllocMaximum()==null) {
		this.jvmMemAllocUseDefaults = true;	
		this.jvmMemAllocInitial = JadeRemoteStart.jvmMemo32MB;
		this.jvmMemAllocMaximum = JadeRemoteStart.jvmMemo128MB;
	} else {
		this.jvmMemAllocUseDefaults = false;
		this.jvmMemAllocInitial = this.reCoCo.getJvmMemAllocInitial();
		this.jvmMemAllocMaximum = this.reCoCo.getJvmMemAllocMaximum();
	}

	// --- Configure Jade settings ------------------------------
	this.jadeIsRemoteContainer = this.reCoCo.getJadeIsRemoteContainer();
	this.jadeShowGUI = this.reCoCo.getJadeShowGUI();	
	
	if (this.reCoCo.getJadeServices()!=null) {
		this.jadeServices = this.reCoCo.getJadeServices();
	}
	if (this.reCoCo.getJadeHost()!=null) {
		this.jadeHost = this.reCoCo.getJadeHost();	
	}
	if (this.reCoCo.getJadePort()!=null) {
		this.jadePort = this.reCoCo.getJadePort();	
	}
	if (this.reCoCo.getJadeContainerName()!=null) {
		this.jadeContainerName = this.reCoCo.getJadeContainerName();	
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:44,代码来源:JadeRemoteStart.java


示例19: CleanUpBehaviour

import jade.core.Agent; //导入依赖的package包/类
public CleanUpBehaviour(Agent a, long period) {
	super(a, period);
	tickingInterval_ms = period;
	tickingInterval_s = tickingInterval_ms / 1000;
	// --- Execute the first 'Tick' right now ------
	this.onTick();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:8,代码来源:ServerMasterAgent.java


示例20: getClassSelector4ProjectAgents

import jade.core.Agent; //导入依赖的package包/类
/**
 * Gets the class selector for project agents.
 * @param project the project
 * @return the class selector for project agents
 */
private ClassSelectionDialog getClassSelector4ProjectAgents(Project project) {
	String currAgentClass = this.getJTextFieldAgentClass().getText();
	if (this.esaClassSelector==null) {
		JListClassSearcher jListClassSearcher = new JListClassSearcher(Agent.class, project.getBundleNames());
		this.esaClassSelector = new ClassSelectionDialog(this.optionDialog, jListClassSearcher, currAgentClass, null, Language.translate("Bitte wählen Sie den Agenten aus, der gestartet werden soll"), false);
	} 
	this.esaClassSelector.setClass2Search4CurrentValue(currAgentClass);
	return this.esaClassSelector;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:15,代码来源:JPanelEmbeddedSystemAgent.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SettingsDecrypter类代码示例发布时间:2022-05-21
下一篇:
Java DateTimeSerializer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap