本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}