本文整理汇总了Java中jade.lang.acl.ACLMessage.createReply方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.createReply方法的具体用法?Java ACLMessage.createReply怎么用?Java ACLMessage.createReply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.createReply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processExecutionControlOntologyMsg
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
boolean processExecutionControlOntologyMsg() {
ACLMessage m = receive(ts);
if (m != null) {
// send the agent state
ACLMessage r = m.createReply();
r.setPerformative(ACLMessage.INFORM);
try {
Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
r.setContentObject((Serializable)agStateDoc);
send(r);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending message " + r, e);
}
}
m = receive(tc);
if (m != null) {
int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
logger.fine("new cycle: "+cycle);
jasonBridgeAgArch.setCycleNumber(cycle);
return true;
}
return false;
}
示例2: action
import jade.lang.acl.ACLMessage; //导入方法依赖的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();
}
}
示例3: processExecutionControlOntologyMsg
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
boolean processExecutionControlOntologyMsg() {
ACLMessage m = receive(ts);
if (m != null) {
// send the agent state
ACLMessage r = m.createReply();
r.setPerformative(ACLMessage.INFORM);
try {
Document agStateDoc = jasonBridgeAgArch.getTS().getAg().getAgState();
r.setContentObject((Serializable)agStateDoc);
send(r);
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending message " + r, e);
}
}
m = receive(tc);
if (m != null) {
int cycle = Integer.parseInt(m.getUserDefinedParameter("cycle"));
logger.fine("new cycle: "+cycle);
jasonBridgeAgArch.setCycleNumber(cycle);
return true;
}
return false;
}
示例4: action
import jade.lang.acl.ACLMessage; //导入方法依赖的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();
}
}
示例5: prepareResultNotification
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
protected ACLMessage prepareResultNotification(ACLMessage request, ACLMessage response) throws FailureException {
try {
AgentAction myAction = this.decodeRequest(request);
if (myAction instanceof FTPUpload) {
if (this.performAction((FTPUpload) myAction)) {
ACLMessage inform = request.createReply();
inform.setPerformative(ACLMessage.INFORM);
return inform;
} else {
logger.fatal("Agent " + this.myAgent.getLocalName() + ": Action failed");
throw new FailureException("unexpected-error");
}
} else {
logger.fatal("Agent " + this.myAgent.getLocalName() + ": Action failed");
throw new FailureException("unexpected-error");
}
} catch (NotUnderstoodException e) {
logger.fatal("Agent " + this.myAgent.getLocalName() + ": Action failed");
throw new FailureException("unexpected-error");
}
}
示例6: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
ACLMessage query_if = receive(MessageTemplate.MatchPerformative(ACLMessage.QUERY_IF));
if (query_if != null && OrderPicker.this.isIdle)
{
ACLMessage response = query_if.createReply();
response.setPerformative(ACLMessage.CONFIRM);
response.setLanguage("JSON");
response.setContent(new JSONObject().put(getLocalName(), true).toString());
send(response);
}
else
{
block();
}
}
示例7: replyUpdateAdvice
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
* Sets and prepares the updates for the client or slave.
* @param msg
*/
private void replyUpdateAdvice(ACLMessage msg) {
// --- Notify that an update is needed ----------------------------
MasterUpdateNote mun = new MasterUpdateNote();
ACLMessage reply = msg.createReply();
sendReply(reply, mun);
}
示例8: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage msg = myAgent.blockingReceive(msgTemplate);
ACLMessage reply = msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
RobotStateContract robotStateContract = sc.Deserialize(RobotStateContract.class, msg.getContent());
System.out.println("state of robot: " + robotStateContract.toString());
reply.setContent(sc.Serialize(updateRobotState(robotStateContract)));
myAgent.send(reply);
}
示例9: answer_guest_ack
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void answer_guest_ack(ACLMessage message) {
ACLMessage reply=message.createReply();
reply.clearAllReceiver();
reply.addReceiver(message.getSender());
reply.setPerformative(ACLMessage.CONFIRM);
reply.setContent(Constance.ROOM_ENTERED);
myAgent.send(reply);
}
示例10: rejectProposals
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void rejectProposals(Collection<ACLMessage> proposals) {
for (final ACLMessage proposal : proposals) {
final ACLMessage response = proposal.createReply();
response.setConversationId(conversationId);
response.setPerformative(ACLMessage.REJECT_PROPOSAL);
myAgent.send(response);
}
}
示例11: failureMessage
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected static ACLMessage failureMessage(ACLMessage request) {
ACLMessage reply = request.createReply();
reply.setPerformative(ACLMessage.FAILURE);
return reply;
}
示例12: informMessage
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected static ACLMessage informMessage(ACLMessage request) {
ACLMessage reply = request.createReply();
reply.setPerformative(ACLMessage.INFORM);
return reply;
}
示例13: answer_exit_req
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void answer_exit_req(ACLMessage message) {
ACLMessage reply=message.createReply();
reply.setPerformative(ACLMessage.CONFIRM);
reply.setContent(Constance.ROOM_QUITTED);
myAgent.send(reply);
}
示例14: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage message = myAgent.receive(MessageTemplate
.MatchProtocol("request-robot"));
if (message != null) {
ACLMessage response = message.createReply();
switch (message.getPerformative()) {
case ACLMessage.REQUEST:
if (isIdle && !promisedProposal) {
response.setPerformative(ACLMessage.PROPOSE);
send(response);
promisedProposal = true;
} else {
response.setPerformative(ACLMessage.REFUSE);
send(response);
}
break;
case ACLMessage.ACCEPT_PROPOSAL:
// TRANSPORT THAT SHELF
isIdle = false;
currentShelf = message.getSender();
myAgent.addBehaviour(new TransportShelfToOrderPicker());
break;
case ACLMessage.REJECT_PROPOSAL:
promisedProposal = false;
break;
case ACLMessage.INFORM:
// SHELF INFORMS US THAT IT WANTS HOME
if (!isIdle) {
myAgent.addBehaviour(new TransportShelfHome());
}
break;
}
} else {
block();
}
}
示例15: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage message = myAgent.receive(MessageTemplate
.MatchProtocol("request-robot"));
if (message != null) {
ACLMessage response = message.createReply();
switch (message.getPerformative()) {
case ACLMessage.PROPOSE:
if (currentState != State.waitForRobot) {
// WE ALREADY HAVE A ROBOT
response.setPerformative(ACLMessage.REJECT_PROPOSAL);
send(response);
} else {
// GOT A ROBOT
log("ACCEPT_PROPOSAL with "
+ message.getSender().getLocalName());
response.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
send(response);
broadcastRobots.stop();
removeBehaviour(broadcastRobots);
// WAIT FOR ARRIVAL
currentState = State.travelToOrderPicker;
currentRobot = message.getSender();
}
break;
case ACLMessage.INFORM:
if (currentState == State.travelToOrderPicker) {
// ARRIVAL AT THE ORDER PICKER
log("INFORM arrived at "
+ currentOrderPicker.getLocalName());
currentState = State.serveOrderPicker;
addBehaviour(new ArriveAtOrderPicker());
} else if (currentState == State.travelBackHome) {
// ARRIVAL HOME
currentPickupWaitBehaviour.stop();
currentState = State.idle;
}
break;
}
} else {
block();
}
}