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 resultAvailable(IParameter[] params) { Map<String, Object> results = new HashMap<String, Object>(); for (int i = 0; i < params.length; ++i) { // String dir = ((IMParameter) params[i].getModelElement()).getDirection(); //System.out.println(params[i].getName() + " " + params[i].getValue() + " " + dir); //if (OAVBDIMetaModel.PARAMETER_DIRECTION_INOUT.equals(dir) || //OAVBDIMetaModel.PARAMETER_DIRECTION_OUT.equals(dir)) results.put(params[i].getName(), params[i].getValue()); } ret.setResult(results); } });
/** * Add a parameter. * @param param The parameter. */ public void addParameter(IParameter param) { if(parameters==null) parameters = new HashMap<String, IParameter>(); parameters.put(param.getName(), param); }
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { getParameter("accept").setValue(Boolean.TRUE); } }
/** * Test if it is the iterated contract-net version. * @return True, if is is the iterated version. */ protected boolean isIterated() { return ((Boolean)getParameter("iterated").getValue()).booleanValue(); }
/** * The plan body. */ public void body() { getParameter("result").setValue(Boolean.TRUE); } }
/** * Test if it is the iterated contract-net version. * @return True, if is is the iterated version. */ protected boolean isIterated() { return ((Boolean)getParameter("iterated").getValue()).booleanValue(); }
/** * The plan body. */ public void body() { Double maxprice = (Double)getBeliefbase().getBelief("max_price").getFact(); Double price = (Double)getParameter("cfp").getValue(); Boolean accept = Boolean.valueOf(price.doubleValue() <= maxprice.doubleValue()); //System.out.println(getAgentName()+" accept="+accept+" price="+price+" max="+maxprice); getParameter("accept").setValue(accept); } }
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { getParameter("result").setValue("request task executed."); } }
/** * Get protocol abbrev name. * @return The protocol abbrev name. */ protected String getShortProtocolName() { String ret; if(SFipa.PROTOCOL_REQUEST.equals(getParameter("protocol").getValue())) ret = "rp"; else ret = "qp"; return ret; } }
/** * Get protocol abbrev name. * @return The protocol abbrev name. */ protected String getShortProtocolName() { String ret; if(SFipa.PROTOCOL_REQUEST.equals(getParameter("protocol").getValue())) ret = "rp"; else ret = "qp"; return ret; } }
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(); } }
/** * The plan body. */ public void body() { Object[] cfps = getParameterSet("history").getValues(); Double newcfp = Double.valueOf(((Double)cfps[cfps.length-1]).doubleValue()+5); getParameter("cfp").setValue(newcfp); }
/** * 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); }
/** * Make a proposal based on the task description. * @param cfp The cfp including the task to execute. * @return The proposal for executing the task. */ public Object[] makeProposal(Object cfp, IComponentIdentifier initiator) { IGoal make_proposal = createGoal(getShortProtocolName()+"_make_proposal"); make_proposal.getParameter("cfp").setValue(cfp); make_proposal.getParameter("initiator").setValue(initiator); dispatchSubgoalAndWait(make_proposal); return new Object[]{make_proposal.getParameter("proposal").getValue(), make_proposal.getParameter("proposal_info").getValue()}; }