/** * Execute the plan. */ public void body() { String eword = (String)((IMessageEvent)getReason()).getParameter(SFipa.CONTENT).getValue(); String gword = (String)wordtable.get(eword); //getLogger().info("Translating from english to german: "+eword+" - "+gword); System.out.println("Translating from english to german: "+eword+" - "+gword); }
/** * 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); }
/** * Handle the ping request. */ public void body() { // Get the initial event. IMessageEvent me = (IMessageEvent)getReason(); // System.out.println("Echo plan invoked: "+me.getParameter(SFipa.CONTENT).getValue()); // Create the reply. IMessageEvent re = getEventbase().createReply(me, "any_message"); re.getParameter(SFipa.PERFORMATIVE).setValue(me.getParameter( SFipa.PERFORMATIVE).getValue()); re.getParameter(SFipa.CONTENT).setValue(me.getParameter( SFipa.CONTENT).getValue()); // Send back the reply and terminate. sendMessage(re); } }
/** * 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); }
/** * Execute a plan. */ public void body() { IMessageEvent querybet = (IMessageEvent)getReason(); // Reply to dealer. IMessageEvent msg = getEventbase().createReply(querybet, "refuse_bet"); msg.getParameter(SFipa.CONTENT).setValue(querybet.getParameter(SFipa.CONTENT).getValue()); getLogger().info("sending decline to the dealer..."); sendMessage(msg); } }
/** * 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); }
public void body() { IMessageEvent updateMsg = (IMessageEvent) getReason(); IGoal handleUpdate = createGoal("sp_handle_update"); handleUpdate.getParameter("subscription_id").setValue(updateMsg.getParameter(SFipa.CONVERSATION_ID).getValue()); handleUpdate.getParameter("update").setValue(updateMsg.getParameter(SFipa.CONTENT).getValue()); dispatchTopLevelGoal(handleUpdate); } }
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(); } }
public void body() { IMessageEvent msg = (IMessageEvent) getReason(); IMessageEvent reply = getEventbase().createReply(msg, "sp_agree"); sendMessage(reply); IGoal startSub = createGoal("sp_start_subscription"); startSub.getParameter("initiator").setValue(msg.getParameter(SFipa.SENDER).getValue()); startSub.getParameter("subscription_id").setValue(msg); startSub.getParameter("subscription").setValue(msg.getParameter(SFipa.CONTENT).getValue()); dispatchSubgoalAndWait(startSub); } }
/** * 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() { Object recontent = ((IMessageEvent)getReason()).getParameter(SFipa.CONTENT).getValue(); TestReport tr = new TestReport("#1", "Send and receive message with custom codec."); // if(content.equals(recontent)) if(recontent instanceof Integer && ((Integer)recontent).intValue()==98) { tr.setSucceeded(true); } else { tr.setReason("Received wrong result: "+recontent); } getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); } }
/** * 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()); } }
/** * */ public void body() { IMessageEvent msg = (IMessageEvent) getParameter("message").getValue(); IMessageEvent update = getEventbase().createReply(msg, "sp_inform"); update.getParameter(SFipa.CONTENT).setValue(getParameter("update").getValue()); sendMessage(update); } }
/** * 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()); } }
/** * Execute the plan. */ public void body() { IMessageEvent rep = getEventbase().createReply((IMessageEvent)getReason(), "not_understood"); rep.getParameter(SFipa.CONTENT).setValue(((IParameterElement)getReason()).getParameter(SFipa.CONTENT).getValue()); sendMessage(rep); // sendMessage(((IMessageEvent)getReason()).createReply( // "not_understood", getReason().getParameter(SFipa.CONTENT).getValue())); } }
/** * 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()); } }
/** * The plan body. */ public void body() { getLogger().info("Created: "+this+" "+getLogger().getName()); //System.out.println("AddPlan found"); IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact(); IMessageEvent req = (IMessageEvent)getReason(); ISpaceObject target = env.getSpaceObject(req.getParameter(SFipa.CONTENT).getValue()); //if(ts.length>0) // System.out.println("Sees: "+SUtil.arrayToString(ts)); if(target!=null&& !getBeliefbase().getBeliefSet("my_targets").containsFact(target)) { //System.out.println("Found a new target: "+target); getBeliefbase().getBeliefSet("my_targets").addFact(target); } } }
/** * The plan body. */ public void body() { getLogger().info("Created: "+this+" "+getLogger().getName()); //System.out.println("AddPlan found"); IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact(); IMessageEvent req = (IMessageEvent)getReason(); ISpaceObject ot = (ISpaceObject)req.getParameter(SFipa.CONTENT).getValue(); ISpaceObject target = env.getSpaceObject(ot.getId()); //if(ts.length>0) // System.out.println("Sees: "+SUtil.arrayToString(ts)); if(target!=null&& !getBeliefbase().getBeliefSet("my_targets").containsFact(target)) { //System.out.println("Found a new target: "+target); getBeliefbase().getBeliefSet("my_targets").addFact(target); } } }
/** * Method body. */ public void body() { getLogger().info("Created: "+this); while(true) { // Wait for a request. IMessageEvent req = waitForMessageEvent("request_carry"); ISpaceObject ot = ((RequestCarry)req.getParameter(SFipa.CONTENT).getValue()).getTarget(); IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact(); ISpaceObject target = env.getSpaceObject(ot.getId()); // Producing ore here. IGoal carry_ore = createGoal("carry_ore"); carry_ore.getParameter("target").setValue(target); dispatchSubgoalAndWait(carry_ore); } } }