/** * Send cfps to all receivers. * @param cfp The cfp. * @param convid The conversation id. * @param receivers The receivers. */ protected void sendCFP(Object cfp, String convid, List receivers) { // Send CFP. IMessageEvent cfpm = getEventbase().createMessageEvent("da_cfp"); cfpm.getParameterSet(SFipa.RECEIVERS).addValues(receivers.toArray()); cfpm.getParameter(SFipa.CONTENT).setValue(cfp); cfpm.getParameter(SFipa.CONVERSATION_ID).setValue(convid); getLogger().info(getComponentName() + ": cfp(" + cfp + ")"); sendMessage(cfpm); }
/** * Send cfps to all receivers. * @param cfp The cfp. * @param convid The conversation id. * @param receivers The receivers. */ protected void sendCFP(Object cfp, String convid, List receivers) { // Send CFP. IMessageEvent cfpm = getEventbase().createMessageEvent("ea_cfp"); cfpm.getParameterSet(SFipa.RECEIVERS).addValues(receivers.toArray()); cfpm.getParameter(SFipa.CONTENT).setValue(cfp); cfpm.getParameter(SFipa.CONVERSATION_ID).setValue(convid); getLogger().info(getComponentName() + ": cfp(" + cfp + ")"); sendMessage(cfpm); }
/** * Announce the planned auction. * @param auctiondesc the auction description. * @param receivers The receivers. * @param convid The conversation id. */ protected void announceAuction(Object auctiondesc, List receivers, String convid) { // Send the inform_start_auction-message to all receivers. start = getEventbase().createMessageEvent("da_inform_start_auction"); start.getParameterSet(SFipa.RECEIVERS).addValues(receivers.toArray()); start.getParameter(SFipa.CONTENT).setValue(auctiondesc); start.getParameter(SFipa.CONVERSATION_ID).setValue(convid); getLogger().info(getComponentName() + ": inform_start_auction"); getWaitqueue().addReply(start); sendMessage(start); }
/** * Announce the planned auction. * @param auctiondesc the auction description. * @param receivers The receivers. * @param convid The conversation id. */ protected void announceAuction(Object auctiondesc, List receivers, String convid) { // Send the inform_start_auction-message to all receivers. start = getEventbase().createMessageEvent("ea_inform_start_auction"); start.getParameterSet(SFipa.RECEIVERS).addValues(receivers.toArray()); start.getParameter(SFipa.CONTENT).setValue(auctiondesc); start.getParameter(SFipa.CONVERSATION_ID).setValue(convid); getLogger().info(getComponentName() + ":\tinform_start_auction"); getWaitqueue().addReply(start); sendMessage(start); }
end.getParameterSet(SFipa.RECEIVERS).addValue(winner); end.getParameter(SFipa.CONVERSATION_ID).setValue(convid); sendMessage(end); end.getParameterSet(SFipa.RECEIVERS).addValues(losers.toArray()); end.getParameter(SFipa.CONVERSATION_ID).setValue(convid); sendMessage(end);
mevent.getParameterSet(SFipa.RECEIVERS).addValue(producers[sel]); mevent.getParameter(SFipa.CONTENT).setValue(rp); sendMessage(mevent);
mevent.getParameterSet(SFipa.RECEIVERS).addValue(producers[sel]); mevent.getParameter(SFipa.CONTENT).setValue(rp); sendMessage(mevent);
/** * First the player searches a dealer, then sends a join-request to this * dealer. */ public void body() { // Search for dealer. IComponentIdentifier dealer = (IComponentIdentifier)getBeliefbase().getBelief("dealer").getFact(); Player me = (Player)getBeliefbase().getBelief("myself").getFact(); // create the join-message IMessageEvent msg = createMessageEvent("request_join"); msg.getParameterSet(SFipa.RECEIVERS).addValue(dealer); RequestJoin rj = new RequestJoin(); rj.setPlayer(me); //msg.setContent("join:" + getAgentName() + ":" + me.getStrategyName() + ":" + me.getAccount() + ":" + Player.color2Hex(me.getColor())); msg.getParameter(SFipa.CONTENT).setValue(rj); getLogger().info("sending join-message"); // send the join-message and wait for a response IMessageEvent reply = sendMessageAndWait(msg, 10000); // evaluate content of the reply-message Object content = reply.getParameter(SFipa.CONTENT).getValue(); if(content instanceof Done) { getLogger().info("request was accepted, timeout is: " + content); getBeliefbase().getBelief("timeout").setFact( Integer.valueOf(((RequestJoin)((Done)content).getAction()).getTimeout())); getBeliefbase().getBelief("dealer").setFact(dealer); } }
/** * The plan body. */ public void body() { ISpaceObject target = ((ChangeEvent<ChangeInfo<ISpaceObject>>)getReason()).getValue().getValue(); // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] sentries = group.getAgentsForRole("sentry"); IMessageEvent mevent = createMessageEvent("inform_target"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(sentries); mevent.getParameter(SFipa.CONTENT).setValue(target); sendMessage(mevent); // System.out.println("Informing sentries: "+getScope().getAgentName()); } }
/** * The plan body. */ public void body() { ISpaceObject target = ((ChangeEvent<ChangeInfo<ISpaceObject>>)getReason()).getValue().getValue(); // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] sentries = group.getAgentsForRole("sentry"); if(sentries!=null) { IMessageEvent mevent = createMessageEvent("inform_target"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(sentries); mevent.getParameter(SFipa.CONTENT).setValue(target); sendMessage(mevent); } // System.out.println("Informing sentries: "+getScope().getAgentName()); } }
mevent.getParameterSet(SFipa.RECEIVERS).addValue(producers[sel].getName()); mevent.getParameter(SFipa.CONTENT).setValue(rp); sendMessage(mevent);
/** * Call carry agents to location. * @param target The target to call carries to. */ protected void callCarryAgent(ISpaceObject target) { // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] carriers = group.getAgentsForRole("carrier"); if(carriers!=null && carriers.length>0) { //System.out.println("Carry Agent: Found Carry Agents: "+carriers.length); RequestCarry rc = new RequestCarry(); rc.setTarget(target); //Action action = new Action(); //action.setAction(rc); //action.setActor(new AID("dummy", true)); // Hack!! What to do with more than one receiver? IMessageEvent mevent = createMessageEvent("request_carries"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(carriers); mevent.getParameter(SFipa.CONTENT).setValue(rc); sendMessage(mevent); //System.out.println("Production Agent sent target to: "+carriers.length); } } }
/** * The plan body. */ public void body() { ISpaceObject target = ((ChangeEvent<ChangeInfo<ISpaceObject>>) getReason()).getValue().getValue(); // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] sentries = group.getAgentsForRole("sentry"); if(sentries!=null) { IMessageEvent mevent = createMessageEvent("inform_target"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(sentries); mevent.getParameter(SFipa.CONTENT).setValue(target.getId()); sendMessage(mevent); } // System.out.println("Informing sentries: "+getScope().getAgentName()); } }
/** * The plan body. */ public void body() { ChangeEvent<ChangeInfo<ISpaceObject>> ce = (ChangeEvent<ChangeInfo<ISpaceObject>>)getReason(); // if (ce.getValue().getValue() == null) // System.out.println("CE: " + ce + " type: " + ce.getType() + " "); // System.out.println("VAL: " + ce.getValue().getValue()); ISpaceObject target = (ce).getValue().getValue(); // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] sentries = group.getAgentsForRole("sentry"); IMessageEvent mevent = createMessageEvent("inform_target"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(sentries); mevent.getParameter(SFipa.CONTENT).setValue(target.getId()); sendMessage(mevent); // System.out.println("Informing sentries: "+getScope().getAgentName()); } }
/** * Call carry agents to location. * @param target The target to call carries to. */ protected void callCarryAgent(ISpaceObject target) { // Todo: multiple spaces by name... AGRSpace agrs = (AGRSpace)EnvironmentService.getSpace(getAgent(), "myagrspace").get(); Group group = agrs.getGroup("mymarsteam"); IComponentIdentifier[] carriers = group.getAgentsForRole("carrier"); if(carriers!=null && carriers.length>0) { //System.out.println("Carry Agent: Found Carry Agents: "+carriers.length); RequestCarry rc = new RequestCarry(); rc.setTarget(target.getId()); //Action action = new Action(); //action.setAction(rc); //action.setActor(new AID("dummy", true)); // Hack!! What to do with more than one receiver? IMessageEvent mevent = createMessageEvent("request_carries"); mevent.getParameterSet(SFipa.RECEIVERS).addValues(carriers); mevent.getParameter(SFipa.CONTENT).setValue(rc); sendMessage(mevent); //System.out.println("Production Agent sent target to: "+carriers.length); } } }
mevent.getParameterSet(SFipa.RECEIVERS).addValue(sentries[i].getName()); mevent.getParameter(SFipa.CONTENT).setValue(target); sendMessage(mevent);
mevent.getParameterSet(SFipa.RECEIVERS).addValue(sentries[i].getName()); mevent.getParameter(SFipa.CONTENT).setValue(target); sendMessage(mevent);
/** * Send the cfp message. * @param nr The current negotation record. * @param convid The conversation id. */ protected void sendCFP(NegotiationRecord nr, String convid) { startAtomic(); if(me!=null) { getWaitqueue().removeReply(me); } me = createMessageEvent(getShortProtocolName()+"_cfp"); me.getParameterSet(SFipa.RECEIVERS).addValues(nr.getParticipants()); me.getParameter(SFipa.CONVERSATION_ID).setValue(convid); me.getParameter(SFipa.CONTENT).setValue(nr.getCFP()); if(getParameter(SFipa.LANGUAGE).getValue()!=null) me.getParameter(SFipa.LANGUAGE).setValue(getParameter(SFipa.LANGUAGE).getValue()); if(getParameter(SFipa.ONTOLOGY).getValue()!=null) me.getParameter(SFipa.ONTOLOGY).setValue(getParameter(SFipa.ONTOLOGY).getValue()); getWaitqueue().addReply(me); endAtomic(); getLogger().info(getComponentName()+" (I)CNPPlan initiated: "+convid); sendMessage(me); }
public void body() { IMessageEvent subReq = createMessageEvent("sp_subscribe"); subReq.getParameter(SFipa.CONTENT).setValue(getParameter("subscription").getValue()); subReq.getParameterSet("receivers").addValue(getParameter("receiver").getValue()); if(getParameter("language").getValue()!=null) subReq.getParameter("language").setValue(getParameter("language").getValue()); if(getParameter("ontology").getValue()!=null) subReq.getParameter("ontology").setValue(getParameter("ontology").getValue()); if(getParameter("conversation_id").getValue()!=null) subReq.getParameter("conversation_id").setValue(getParameter("conversation_id").getValue()); getParameter("subscription_id").setValue(subReq.getParameter(SFipa.CONVERSATION_ID)); getWaitqueue().addReply(subReq); IMessageEvent reply = sendMessageAndWait(subReq); if (!SFipa.AGREE.equals(reply.getParameter(SFipa.PERFORMATIVE).getValue())) fail(); } }
request.getParameter(SFipa.CONTENT).setValue(getParameter("action").getValue()); request.getParameterSet("receivers").addValue(getParameter("receiver").getValue()); if(getParameter("language").getValue()!=null) request.getParameter("language").setValue(getParameter("language").getValue());