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


Java MessageTemplate.MatchPerformative方法代码示例

本文整理汇总了Java中jade.lang.acl.MessageTemplate.MatchPerformative方法的典型用法代码示例。如果您正苦于以下问题:Java MessageTemplate.MatchPerformative方法的具体用法?Java MessageTemplate.MatchPerformative怎么用?Java MessageTemplate.MatchPerformative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jade.lang.acl.MessageTemplate的用法示例。


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

示例1: action

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
@Override
public void action() {
    MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP);
    ACLMessage msg = myAgent.receive();

    if (msg != null) {
        parseContent(msg.getContent());

        ACLMessage reply = msg.createReply();
        int bid;

        if (itemPrice < wallet / 4) {
            // Place a bid 5 to 10% higher than the received value
            bid = (int) (itemPrice + itemPrice * ((float) ThreadLocalRandom.current().nextInt(5, 10) / 10));

            reply.setPerformative(ACLMessage.PROPOSE);
            reply.setContent(String.valueOf(bid));
        } else {
            reply.setPerformative(ACLMessage.REFUSE);
        }

        myAgent.send(reply);
    } else {
        block();
    }
}
 
开发者ID:ohvitorino,项目名称:auctions,代码行数:27,代码来源:BidderAgent.java

示例2: action

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
public void action() {
    MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP);
    ACLMessage msg = myAgent.receive(mt);
    if (msg != null) {
        // CFP Message received. Process it
        String title = msg.getContent();
        ACLMessage reply = msg.createReply();

        Integer price = (Integer) catalogue.get(title);
        if (price != null) {
            // The requested book is available for sale. Reply with the price
            reply.setPerformative(ACLMessage.PROPOSE);
            reply.setContent(String.valueOf(price.intValue()));
        } else {
            // The requested book is NOT available for sale.
            reply.setPerformative(ACLMessage.REFUSE);
            reply.setContent("not-available");
        }
        myAgent.send(reply);
    } else {
        block();
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:24,代码来源:BookSellerAgent.java

示例3: onWake

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
@Override
protected void onWake() {
	final MessageTemplate mtMatchingMsgId = MessageTemplate.MatchInReplyTo(messageId);
	final MessageTemplate mtMatchingPerformative = MessageTemplate.MatchPerformative(ACLMessage.PROPOSE);
	final MessageTemplate mt = MessageTemplate.and(mtMatchingMsgId, mtMatchingPerformative);
	final Collection<ACLMessage> proposals = new HashSet<>();
	ACLMessage proposal;
	while ((proposal = myAgent.receive(mt)) != null) {
		proposals.add(proposal);
	}
	final ACLMessage bestProposal = caller.chooseProposal(conversationId, proposals);
	if (bestProposal != null) {
		acceptProposal(bestProposal);
		final Collection<ACLMessage> others = proposals.stream().filter(p -> !p.equals(bestProposal)).collect(Collectors.toList());
		rejectProposals(others);
	}
}
 
开发者ID:overheadhunter,项目名称:jade-factory,代码行数:18,代码来源:CallingForProposalBehaviour.java

示例4: action

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
public void action() {
	MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CFP);
	ACLMessage msg = myAgent.receive(mt);
	if (msg != null) {
		// CFP Message received. Process it
		String title = msg.getContent();
		ACLMessage reply = msg.createReply();

		Integer price = (Integer) catalogue.get(title);
		if (price != null) {
			// The requested book is available for sale. Reply with the price
			reply.setPerformative(ACLMessage.PROPOSE);
			reply.setContent(String.valueOf(price.intValue()));
		}
		else {
			// The requested book is NOT available for sale.
			reply.setPerformative(ACLMessage.REFUSE);
			reply.setContent("not-available");
		}
		myAgent.send(reply);
	}
	else {
		block();
	}
}
 
开发者ID:bluezio,项目名称:jade-booktrading,代码行数:26,代码来源:BookSellerAgent.java

示例5: setup

import jade.lang.acl.MessageTemplate; //导入方法依赖的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

示例6: setup

import jade.lang.acl.MessageTemplate; //导入方法依赖的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

示例7: action

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
@Override
public void action() {
	if (first) {
		AID server_name = myAgent.getServerName();
		if (server_name != null){
			msg.clearAllReceiver();
			msg.addReceiver(server_name);
			msg.setContent(Constance.roomselect_Mode);
			MyAID sound_agent = new MyAID(myAgent.getMySoundAgent().getName(), myAgent.getMySoundAgent().getAddressesArray()[0]);	
			msg.setReplyWith(sound_agent.toJSON());	
			myAgent.send(msg);
			first = false;
			System.out.println("Ask for creating room sent");
		} else {
			System.out.println("server not found");
		}
	} else {
		MessageTemplate mt = MessageTemplate.MatchPerformative(ACLMessage.CONFIRM);
		ACLMessage message=myAgent.receive(mt);
		
		if(message != null){
			myAgent.addBehaviour(new ModeSelectBehaviour(myAgent, Constance.roomselect_Mode));
			done = true;
			System.out.println("room created, behaviour done");
			myAgent.setRoomId(message.getContent());
			myAgent.addBehaviour(new LocalGameDaemonBehaviour(myAgent));
		}
	}
	
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:31,代码来源:CreatGroupBehaviour.java

示例8: setupConfiguration5

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
private void setupConfiguration5(Object[] arguments) {
    MessageTemplate template = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
    addBehaviour(new RequestServer(template, 0));
    logger.fine("RequestServer behaviour added");

    setMessageReceived(false);
    long timeToWait = 200;
    try {
        Thread.sleep(timeToWait);
    } catch (InterruptedException e) {
        logger.severe(this.getName() + " could not wait " + timeToWait
                + " milliseconds. Exception: " + e);
    }      
    
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:16,代码来源:TesterAgent.java

示例9: setupConfiguration6

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
private void setupConfiguration6(Object[] arguments) {
    MessageTemplate template = MessageTemplate.MatchPerformative(ACLMessage.REQUEST);
    addBehaviour(new RequestServer(template, 1));
    logger.fine("RequestServer behaviour added");
    
    long timeToWait = 200;
    try {
        Thread.sleep(timeToWait);
    } catch (InterruptedException e) {
        logger.severe(this.getName() + " could not wait " + timeToWait
                + " milliseconds. Exception: " + e);
    }
    
}
 
开发者ID:gsi-upm,项目名称:BeastTool,代码行数:15,代码来源:TesterAgent.java

示例10: RobotPositionResponder

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
public RobotPositionResponder(Agent a, Grid grid) {
		super(a);
		msgTemplate = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
//		this.grid = grid;
	}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:6,代码来源:RobotPositionResponder.java

示例11: action

import jade.lang.acl.MessageTemplate; //导入方法依赖的package包/类
@Override
public void action() {
	MessageTemplate mt = MessageTemplate
			.MatchPerformative(ACLMessage.INFORM);
	ACLMessage aclMsg = myAgent.receive(mt);
	if (aclMsg != null) {
		// Message matching the template has come in.
		String msgStr = aclMsg.getContent();

		FrameworkMessage message = null;
		try {
			message = new FrameworkMessageImpl(
					SYSTEM_TYPE.DISTRIBUTED_SYSTEM,
					SYSTEM_TYPE.SIMULATION_ENGINE, msgStr);
		} catch (CsfCheckedException e) {
			// FIXME: Remove all of the agents/shutdown the MAS?
			System.out
			.println("[JADE Controller Agent] Error converting message from a distributed JADE agent to the JADE Controller Agent: "
					+ msgStr);
			doDelete();
			e.printStackTrace();
		}

		System.out
		.println("[JADE Controller Agent] Received the distributed autonomous agent (model) decision. Forwarding to the simulation engine (agent)");

		jade_MAS_RunContext.messageSimulationEngine(message,
				jade_MAS_RunContext.getDistSysRunContext());

		FRAMEWORK_COMMAND fc = getJade_MAS_RunContext()
				.waitForAndProcessSimulationEngineMessageAfterHandshake();
		if (fc == FRAMEWORK_COMMAND.STOP_SIMULATION) {
			System.out
			.println("[JADE Controller Agent] Received Stop Simulation Command from Simulation Engine.  Listening for new simulation run");
			setupNewSimulationRun();
		}

	} else {
		block(); // Save CPU cycles by not executing this thread until
		// new messages come in.
	}

}
 
开发者ID:OpenSimulationSystems,项目名称:CABSF_Java,代码行数:44,代码来源:JADE_Controller_Agent.java


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