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


Java ACLMessage.createReply方法代码示例

本文整理汇总了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;
}
 
开发者ID:nickrfer,项目名称:code-sentinel,代码行数:25,代码来源:JadeAgArch.java

示例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();
    }
}
 
开发者ID:ohvitorino,项目名称:auctions,代码行数:27,代码来源:BidderAgent.java

示例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;
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:25,代码来源:JadeAgArch.java

示例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();
    }
}
 
开发者ID:jason-lang,项目名称:jason,代码行数:24,代码来源:BookSellerAgent.java

示例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");
    }
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:23,代码来源:FTPUploadRequestResponderBehaviour.java

示例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();
	}
}
 
开发者ID:autarchprinceps,项目名称:Multiagent-Warehouse,代码行数:18,代码来源:OrderPicker.java

示例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);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:11,代码来源:ServerMasterAgent.java

示例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);
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:11,代码来源:RobotPositionResponder.java

示例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);
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:9,代码来源:GameManageBehaviour.java

示例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);
	}
}
 
开发者ID:overheadhunter,项目名称:jade-factory,代码行数:9,代码来源:CallingForProposalBehaviour.java

示例11: failureMessage

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected static ACLMessage failureMessage(ACLMessage request) {
	ACLMessage reply = request.createReply();
	reply.setPerformative(ACLMessage.FAILURE);
	return reply;
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:6,代码来源:StationCommunicator.java

示例12: informMessage

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
protected static ACLMessage informMessage(ACLMessage request) {
	ACLMessage reply = request.createReply();
	reply.setPerformative(ACLMessage.INFORM);
	return reply;
}
 
开发者ID:gseteamproject,项目名称:gseproject,代码行数:6,代码来源:StationCommunicator.java

示例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);
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:7,代码来源:GameManageBehaviour.java

示例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();
	}

}
 
开发者ID:autarchprinceps,项目名称:Multiagent-Warehouse,代码行数:54,代码来源:RobotAgent.java

示例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();
	}

}
 
开发者ID:autarchprinceps,项目名称:Multiagent-Warehouse,代码行数:61,代码来源:ShelfAgent.java


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