本文整理汇总了Java中jade.lang.acl.ACLMessage.setPerformative方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.setPerformative方法的具体用法?Java ACLMessage.setPerformative怎么用?Java ACLMessage.setPerformative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.setPerformative方法的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 reply=msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
reply.setConversationId(Constance.GROUP_CREATED);
try {
reply.setContentObject(myAgent.getDict());
System.out.println("set defautlistmodele of reply\n");
myAgent.send(reply);
System.out.println("multiAgent sent reply\n");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: answer
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void answer(){
ACLMessage reply=msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
//String listString="";
/*for(String s:myAgent.getDict()){
listString+=s+",";
}*/
try {
reply.setContentObject(myAgent.getDict());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myAgent.send(reply);
}
示例8: 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();
}
}
示例9: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
// If the game is not running or Pacman is marked
// for death, doesn't move
if (!( // If not
((PacmanAgent) myAgent).isGameRunning() // ... game is running
&& !((PacmanAgent) myAgent).isShouldDie() // ... Pacman is not marked for death
))
{
System.out.println(myAgent.getLocalName() + " cannot move!");
// Replies to the Game Agent denying this behaviour
ACLMessage reply = originMessage.createReply();
reply.setPerformative(ACLMessage.REFUSE);
reply.setContent(GameVocabulary.MOVED_MY_BODY);
myAgent.send(reply);
// Updates the GhostAgent state
((PacmanAgent) myAgent).setMoving(false);
// Removes this behaviour from Pacman
myAgent.removeBehaviour(this);
return;
}
synchronized(this)
{
move(); // Pacman makes a movement
checkGhostInSamePath(); // Pacman checks if there is a ghost in the same path as it
}
}
示例10: 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);
}
示例11: addBlockToMessage
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private static ACLMessage addBlockToMessage(ACLMessage message, Block block) {
if (block == null) {
message.setPerformative(ACLMessage.FAILURE);
return message;
}
try {
message.setContentObject(block);
} catch (IOException e) {
e.printStackTrace();
message.setPerformative(ACLMessage.FAILURE);
return message;
}
return message;
}
示例12: answer_host_ack
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void answer_host_ack() {
ACLMessage reply=host_msg.createReply();
reply.setPerformative(ACLMessage.CONFIRM);
reply.setContent(conversation_id);
System.out.println("send host ack");
myAgent.send(reply);
}
示例13: 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);
}
示例14: 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);
}
}
示例15: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
// If the game is not running, the ghost still didn't
// left his house or it's marked for death, doesn't move
if (!( // If not
((GhostAgent) myAgent).isGameRunning() // ... game is running
&& ((GhostAgent) myAgent).isHouseLeft() // ... the ghost left its house
&& !((GhostAgent) myAgent).isShouldDie() // ... the ghost is not marked for death
))
{
System.out.println(myAgent.getLocalName() + " cannot move!");
// Replies to the Game Agent denying this behaviour
ACLMessage reply = originMessage.createReply();
reply.setPerformative(ACLMessage.REFUSE);
reply.setContent(GameVocabulary.MOVED_MY_BODY);
myAgent.send(reply);
// Updates the GhostAgent state
((GhostAgent) myAgent).setMoving(false);
// Removes this behaviour from the ghost
myAgent.removeBehaviour(this);
return;
}
synchronized (this)
{
// If the ghost received "GET_OUT_MY_WAY", maybe it reverses the
// direction being followed
if (((GhostAgent) myAgent).isReverseDirection())
{
maybeReverseDirection();
}
move(); // Ghost makes a movement
checkGhostOnSamePath(); // Ghost checks if are there another ghosts on the same path
checkPacmanOnSamePath(); // Ghost checks if Pacman is in the same path as it
}
}