本文整理汇总了Java中jade.lang.acl.ACLMessage.addReceiver方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.addReceiver方法的具体用法?Java ACLMessage.addReceiver怎么用?Java ACLMessage.addReceiver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.addReceiver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGameEnd
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void handleGameEnd()
{
// If the game still has remaining ghosts and collectibles,
// Pacman still didn't won the game
int remainingGhosts = (int) board.getGhosts()
.stream()
.filter(ghost -> !ghost.isShouldDie())
.count();
if (0 < remainingGhosts && board.hasRemainingCollectibles())
{
return;
}
// Else, informs Game agent the game has been won (and should end)
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setOntology(GameVocabulary.ONTOLOGY);
message.setContent(GameVocabulary.END_PACMAN_WINS);
message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
myAgent.send(message);
}
示例2: die
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void die()
{
// Marks the ghost for dying
setShouldDie(true);
// Notifies other ghosts so they can run
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setOntology(GhostVocabulary.ONTOLOGY);
message.setContent(GhostVocabulary.THE_MOTHERFUCKER_KILLED_ME);
board.getGhosts()
.stream()
.filter(ghost -> !ghost.equals(this))
.forEach(ghost -> message.addReceiver(ghost.getAID()));
send(message);
// Notifies GameAgent I'm dead
message.clearAllReceiver();
message.setOntology(GameVocabulary.ONTOLOGY);
message.setContent(GameVocabulary.GHOST_KILLED);
message.addReceiver(new AID(Constant.GAME_AGENT_NAME, AID.ISLOCALNAME));
send(message);
// Effectively dies
doDelete();
}
示例3: informAgsEnvironmentChanged
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void informAgsEnvironmentChanged(Collection<String> agentsToNotify) {
try {
if (agentsToNotify == null) {
informAgsEnvironmentChanged();
} else {
ACLMessage m = new ACLMessage(ACLMessage.INFORM);
m.setContent("environmentChanged");
for (String ag: agentsToNotify) {
m.addReceiver(new AID(ag, AID.ISLOCALNAME));
}
send(m);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error sending notifyEvents ", e);
}
}
示例4: perceive
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
if (!isRunning()) return null;
if (getEnvironmentAg() == null) return null;
@SuppressWarnings("rawtypes")
List percepts = null;
try {
ACLMessage askMsg = new ACLMessage(ACLMessage.QUERY_REF);
askMsg.addReceiver(environmentAID);
askMsg.setOntology(JadeEnvironment.perceptionOntology);
askMsg.setContent("getPercepts");
ACLMessage r = jadeAg.ask(askMsg);
if (r != null && r.getContent().startsWith("[")) {
percepts = ListTermImpl.parseList(r.getContent());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in perceive.", e);
}
return percepts;
}
示例5: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
myAgent.getContentManager().registerLanguage(new SLCodec(), FIPANames.ContentLanguage.FIPA_SL0);
myAgent.getContentManager().registerOntology(JADEManagementOntology.getInstance());
ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
msg.addReceiver(myAgent.getDefaultDF());
msg.setOntology(JADEManagementOntology.NAME);
msg.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
msg.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
Action a = new Action();
a.setActor( myAgent.getDefaultDF() );
a.setAction( new ShowGui() );
try {
myAgent.getContentManager().fillContent(msg,a);
} catch (Exception e) {
e.printStackTrace();
}
myAgent.send(msg);
myAgent.doDelete();
}
示例6: 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);
}
}
示例7: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
ResultsAgent a = (ResultsAgent)myAgent;
// Send result before closing down
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(a.getAID());
msg.addReceiver(new AID(SendTo, false));
try {
Object[] oMsg=new Object[3];
oMsg[0] = ID;
oMsg[1] = bText1;
oMsg[2] = bText2;
msg.setContentObject(oMsg);
} catch (IOException ex) {
System.err.println("Cannot add result to message. Sending empty message.");
ex.printStackTrace(System.err);
}
a.send(msg);
}
示例8: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/** Actually sends the result to the dispatching agent.
*/
public void action() {
synchronized (myAgent) {
NGramDocumentComparatorAgent a = (NGramDocumentComparatorAgent)myAgent;
// Send result before closing down
ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
msg.setSender(a.getAID());
msg.addReceiver(a.ResultConsumer);
try {
msg.setContentObject(Result);
} catch (IOException ex) {
System.err.println("Cannot add result to message. Sending empty message.");
ex.printStackTrace(System.err);
}
a.send(msg);
}
}
示例9: addAllAgsAsReceivers
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void addAllAgsAsReceivers(ACLMessage m) throws Exception {
// get all agents' name
DFAgentDescription template = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("jason");
sd.setName(JadeAgArch.dfName);
template.addServices(sd);
DFAgentDescription[] ans = DFService.search(this, template);
for (int i=0; i<ans.length; i++) {
if (!ans[i].getName().equals(getAID())) {
m.addReceiver(ans[i].getName());
}
}
}
示例10: perceive
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public List<Literal> perceive() {
super.perceive();
if (!isRunning()) return null;
if (getEnvironmentAg() == null) return null;
@SuppressWarnings("rawtypes")
List percepts = null;
try {
ACLMessage askMsg = new ACLMessage(ACLMessage.QUERY_REF);
askMsg.addReceiver(environmentAID);
askMsg.setOntology(JadeEnvironment.perceptionOntology);
askMsg.setContent("getPercepts");
ACLMessage r = jadeAg.ask(askMsg);
if (r != null && r.getContent().startsWith("[")) {
percepts = ListTermImpl.parseList(r.getContent());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Error in perceive.", e);
}
return percepts;
}
示例11: 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);
}
}
示例12: 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);
}
示例13: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action()
{
removeBehaviour(OrderPicker.this.abortOrder);
removeBehaviour(OrderPicker.this.shelfInteraction);
log("Order complete, send INFORM to " + OrderPicker.this.currentOrderAgent.getLocalName() + "!");
ACLMessage inform = new ACLMessage(ACLMessage.INFORM);
inform.addReceiver(OrderPicker.this.currentOrderAgent);
inform.setLanguage("JSON");
inform.setProtocol("JSON");
inform.setContent(OrderPicker.this.orderOutgoing.toString());
send(inform);
OrderPicker.this.itemStatus.clear();
OrderPicker.this.shelfInfo.clear();
OrderPicker.this.orderOutgoing = null;
OrderPicker.this.orderOutgoing = new JSONArray();
OrderPicker.this.isIdle = true;
removeBehaviour(this);
}
示例14: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage recMsg = receive(MessageTemplate.MatchPerformative(ACLMessage.INFORM));
if(recMsg != null) {
ACLMessage response = new ACLMessage(ACLMessage.INFORM);
Order ordr = unfinishedOrders.get(recMsg.getSender());
for(AID rec : ordr.requestingAgents) {
response.addReceiver(rec);
}
response.setLanguage("JSON");
StringBuilder sb = new StringBuilder("{id:");
sb.append(ordr.id).append(",list:[");
for(Pair<String, Integer> p : ordr.items) {
sb.append(p.getFirst()).append(":").append(p.getSecond()).append(",");
}
sb.deleteCharAt(sb.length() - 1);
sb.append("]}");
response.setContent(sb.toString());
System.out.println("WarehouseAgent: Sending completed order to customer: " + ordr.id);
send(response);
} else {
block();
}
}
示例15: requestOrder
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void requestOrder() {
DFAgentDescription template = new DFAgentDescription();
ServiceDescription sd = new ServiceDescription();
sd.setType("giveOrder");
template.addServices(sd);
try {
DFAgentDescription[] result = DFService.search(myAgent,
template);
ACLMessage msg = new ACLMessage(ACLMessage.REQUEST);
for (DFAgentDescription agent : result) {
msg.addReceiver(agent.getName());
send(msg);
}
} catch (FIPAException fe) {
fe.printStackTrace();
}
}