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


Java ACLMessage.setReplyWith方法代码示例

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


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

示例1: act

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) { //, List<ActionExec> feedback) {
    if (!isRunning()) return;
    if (getEnvironmentAg() == null) return;
    
    try {
        Term acTerm = action.getActionTerm();
        logger.fine("doing: " + acTerm);

        String rw  = "id"+jadeAg.incReplyWithId();
        ACLMessage m = new ACLMessage(ACLMessage.REQUEST);
        m.addReceiver(environmentAID);
        m.setOntology(JadeEnvironment.actionOntology);
        m.setContent(acTerm.toString());
        m.setReplyWith(rw);
        myPA.put(rw, action); 
        jadeAg.send(m);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error sending action " + action, e);
    }
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:22,代码来源:JasonBridgeArch.java

示例2: act

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void act(ActionExec action) {
    if (!isRunning()) return;
    if (getEnvironmentAg() == null) return;

    try {
        Term acTerm = action.getActionTerm();
        logger.fine("doing: " + acTerm);

        String rw  = "id"+jadeAg.incReplyWithId();
        ACLMessage m = new ACLMessage(ACLMessage.REQUEST);
        m.addReceiver(environmentAID);
        m.setOntology(JadeEnvironment.actionOntology);
        m.setContent(acTerm.toString());
        m.setReplyWith(rw);
        myPA.put(rw, action);
        jadeAg.send(m);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error sending action " + action, e);
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:22,代码来源:JasonBridgeArch.java

示例3: receiveMessage

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void receiveMessage(final FrameworkMessage msg, final String messageID,
		final String inReplyToMessageID, final JadeControllerMock jade_ControllerMock) {
	final ACLMessage aclMsg = new ACLMessage(ACLMessage.INFORM);
	aclMsg.addReceiver(aid);
	aclMsg.setContent(msg.toPrettyPrintedXMLString());
	aclMsg.setConversationId("jade-controller");
	aclMsg.setReplyWith(UUID.randomUUID().toString());

	System.out
			.println("[JADE Controller Agent ] Sending message to distributed JADE Agent: "
					+ distributedSystemID
					+ " "
					+ distributedAutonomousAgentID
					+ " "
					+ distAutAgentModelID);
	jadeControllerAgent.send(aclMsg);

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

示例4: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
	try {
		final Date proposalDeadline = caller.getProposalDeadline(conversationId);
		final Collection<DFAgentDescription> stationAgents = getCfpRecipients();
		final ACLMessage cfp = new ACLMessage(ACLMessage.CFP);
		cfp.setConversationId(conversationId);
		cfp.setReplyWith(messageId);
		cfp.setReplyByDate(proposalDeadline);
		for (final DFAgentDescription agent : stationAgents) {
			cfp.addReceiver(agent.getName());
		}
		caller.configureCfp(conversationId, cfp);
		myAgent.send(cfp);
		myAgent.addBehaviour(new CollectProposalsBehaviour(proposalDeadline));
	} catch (FIPAException e) {
		LOG.error("Unable to contact stations.", e);
	}
}
 
开发者ID:overheadhunter,项目名称:jade-factory,代码行数:20,代码来源:CallingForProposalBehaviour.java

示例5: ask

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected ACLMessage ask(final ACLMessage m) {
    try {
        String waitingRW = "id"+incReplyWithId();
        m.setReplyWith(waitingRW);
        send(m);                    
        ACLMessage r = blockingReceive(MessageTemplate.MatchInReplyTo(waitingRW), 5000);
        if (r != null) 
            return r;
        else 
            logger.warning("ask timeout for "+m.getContent());
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error waiting message.", e);            
    }
    return null;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:16,代码来源:JadeAg.java

示例6: jasonToACL

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected ACLMessage jasonToACL(Message m) throws IOException {
    ACLMessage acl = kqmlToACL(m.getIlForce());
    // send content as string if it is a Term/String (it is better for interoperability)
    if (m.getPropCont() instanceof Term || m.getPropCont() instanceof String) {
        acl.setContent(m.getPropCont().toString());         
    } else {
        acl.setContentObject((Serializable)m.getPropCont());
    }
    acl.setReplyWith(m.getMsgId());
    acl.setLanguage("AgentSpeak");
    if (m.getInReplyTo() != null) {
        acl.setInReplyTo(m.getInReplyTo());
    }
    return acl;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:16,代码来源:JadeAg.java

示例7: ask

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected ACLMessage ask(final ACLMessage m) {
    try {
        String waitingRW = "id"+incReplyWithId();
        m.setReplyWith(waitingRW);
        send(m);
        ACLMessage r = blockingReceive(MessageTemplate.MatchInReplyTo(waitingRW), 5000);
        if (r != null)
            return r;
        else
            logger.warning("ask timeout for "+m.getContent());
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error waiting message.", e);
    }
    return null;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:16,代码来源:JadeAg.java

示例8: jasonToACL

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected ACLMessage jasonToACL(Message m) throws IOException {
    ACLMessage acl = kqmlToACL(m.getIlForce());
    // send content as string if it is a Term/String (it is better for interoperability)
    if (m.getPropCont() instanceof Term || m.getPropCont() instanceof String) {
        acl.setContent(m.getPropCont().toString());
    } else {
        acl.setContentObject((Serializable)m.getPropCont());
    }
    acl.setReplyWith(m.getMsgId());
    acl.setLanguage("AgentSpeak");
    if (m.getInReplyTo() != null) {
        acl.setInReplyTo(m.getInReplyTo());
    }
    return acl;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:16,代码来源:JadeAg.java

示例9: info_all_player_start_game

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void info_all_player_start_game(ACLMessage m) {
	ACLMessage info_game_start = new ACLMessage(ACLMessage.CONFIRM);
	for (int i = 0; i < list_member.size(); i++) {
		info_game_start.addReceiver(list_member.get(i));
	}
	info_game_start.setConversationId(m.getConversationId());
	info_game_start.setSender(myAgent.getAID());
	MyAID sound_agent = new MyAID(host_sound_name.getName(), host_sound_name.getAddressesArray()[0]);
	info_game_start.setReplyWith(sound_agent.toJSON());
	info_game_start.setContent(Constance.CONFIRM_START);
	myAgent.send(info_game_start);
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:13,代码来源:GameManageBehaviour.java

示例10: info_all_player_change_sound_name

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void info_all_player_change_sound_name(ACLMessage m) {
	ACLMessage info_sound_change = new ACLMessage(ACLMessage.CONFIRM);
	for (int i = 0; i < list_member.size(); i++) {
		info_sound_change.addReceiver(list_member.get(i));
	}
	info_sound_change.setConversationId(m.getConversationId());
	info_sound_change.setSender(myAgent.getAID());
	MyAID sound_agent = new MyAID(host_sound_name.getName(), host_sound_name.getAddressesArray()[0]);
	info_sound_change.setReplyWith(sound_agent.toJSON());
	info_sound_change.setContent(Constance.Sound_Change);
	myAgent.send(info_sound_change);
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:13,代码来源:GameManageBehaviour.java

示例11: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
    switch (step) {
    case 0:
        // Send the cfp to all sellers
        ACLMessage cfp = new ACLMessage(ACLMessage.CFP);
        for (int i = 0; i < sellerAgents.length; ++i) {
            cfp.addReceiver(sellerAgents[i]);
        }
        cfp.setContent(targetBookTitle);
        cfp.setConversationId("book-trade");
        cfp.setReplyWith("cfp"+System.currentTimeMillis()); // Unique value
        myAgent.send(cfp);
        // Prepare the template to get proposals
        mt = MessageTemplate.and(MessageTemplate.MatchConversationId("book-trade"),
                                 MessageTemplate.MatchInReplyTo(cfp.getReplyWith()));
        step = 1;
        break;
    case 1:
        // Receive all proposals/refusals from seller agents
        ACLMessage reply = myAgent.receive(mt);
        if (reply != null) {
            // Reply received
            if (reply.getPerformative() == ACLMessage.PROPOSE) {
                // This is an offer
                int price = Integer.parseInt(reply.getContent());
                if (bestSeller == null || price < bestPrice) {
                    // This is the best offer at present
                    bestPrice = price;
                    bestSeller = reply.getSender();
                }
            }
            repliesCnt++;
            if (repliesCnt >= sellerAgents.length) {
                // We received all replies
                step = 2;
            }
        } else {
            block();
        }
        break;
    case 2:
        // Send the purchase order to the seller that provided the best offer
        ACLMessage order = new ACLMessage(ACLMessage.ACCEPT_PROPOSAL);
        order.addReceiver(bestSeller);
        order.setContent(targetBookTitle);
        order.setConversationId("book-trade");
        order.setReplyWith("order"+System.currentTimeMillis());
        myAgent.send(order);
        // Prepare the template to get the purchase order reply
        mt = MessageTemplate.and(MessageTemplate.MatchConversationId("book-trade"),
                                 MessageTemplate.MatchInReplyTo(order.getReplyWith()));
        step = 3;
        break;
    case 3:
        // Receive the purchase order reply
        reply = myAgent.receive(mt);
        if (reply != null) {
            // Purchase order reply received
            if (reply.getPerformative() == ACLMessage.INFORM) {
                // Purchase successful. We can terminate
                System.out.println(targetBookTitle+" successfully purchased from agent "+reply.getSender().getName());
                System.out.println("Price = "+bestPrice);
                myAgent.doDelete();
            } else {
                System.out.println("Attempt failed: requested book already sold.");
            }

            step = 4;
        } else {
            block();
        }
        break;
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:75,代码来源:BookBuyerAgent.java


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