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); } });
/** * 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); } }
IMParameter mp = (IMParameter)p.getModelElement(); if(OAVBDIMetaModel.PARAMETER_DIRECTION_IN.equals(mp.getDirection()) || OAVBDIMetaModel.PARAMETER_DIRECTION_INOUT.equals(mp.getDirection())) ret[i] = p.getValue(); set = true; it.remove();
IMParameter mp = (IMParameter)p.getModelElement(); if(OAVBDIMetaModel.PARAMETER_DIRECTION_IN.equals(mp.getDirection())) p.setValue(args[i]); set = true; it.remove();
/** * 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(); }
/** * Method, that is being called, when the request has finished. * Default implementation sets status and result on goal. * @param success The final status of the df search. * @param result The result object. */ protected void requestFinished(boolean success, Object result) { getLogger().info("Request finished with: "+success+" "+ SUtil.arrayToString(result)+" "+this+" "+getComponentName()); getParameter("result").setValue(result); if(!success) fail(); }
for(int i=0; i<params.length; i++) IMParameter mp = (IMParameter)params[i].getModelElement(); Class<?> mpclass = mp.getClazz(); String dir = ((IMParameter)params[i].getModelElement()).getDirection(); if((OAVBDIMetaModel.PARAMETER_DIRECTION_INOUT.equals(dir) || OAVBDIMetaModel.PARAMETER_DIRECTION_OUT.equals(dir)) && SReflect.isSupertype(mpclass, rt)) rval = params[i].getValue(); set = true; break; String dir = ((IMParameter)params[i].getModelElement()).getDirection(); if((OAVBDIMetaModel.PARAMETER_DIRECTION_INOUT.equals(dir) || OAVBDIMetaModel.PARAMETER_DIRECTION_OUT.equals(dir)) && SReflect.isSupertype(mps.getClazz(), rt.getComponentType()))
/** * The body method is called on the * instantiated plan instance from the scheduler. */ public void body() { // long timeout; // if(getParameter("timeout").getValue()!=null) // timeout = ((Long)getParameter("timeout").getValue()).longValue(); // else // timeout = -1; // Send ping and wait for answer. IGoal query = createGoal("procap.qp_initiate"); query.getParameter("receiver").setValue(getParameter("receiver").getValue()); query.getParameter("timeout").setValue(getParameter("timeout").getValue()); query.getParameter("action").setValue(getParameter("content").getValue()); dispatchSubgoalAndWait(query); } }
/** * 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; } }
/** * 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); }
/** * The body method is called on the * instatiated plan instance from the scheduler. */ public void body() { CMSShutdownPlatform sp = new CMSShutdownPlatform(); IGoal req = createGoal("rp_initiate"); req.getParameter("receiver").setValue(getParameter("cms").getValue()); req.getParameter("action").setValue(sp); req.getParameter("ontology").setValue(SFipa.COMPONENT_MANAGEMENT_ONTOLOGY_NAME); dispatchSubgoalAndWait(req); } }
/** * 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; } }
/** * 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); }
/** * Decide about the request. * @param request The request. * @param initiator The requesting agent. * @return True, if should send agree. False for sending refuse. Exception/null for sending nothing. */ public Boolean decideRequest(Object request, IComponentIdentifier initiator) { IGoal decide_request = createGoal("rp_decide_request"); decide_request.getParameter("action").setValue(request); decide_request.getParameter("initiator").setValue(initiator); dispatchSubgoalAndWait(decide_request); return (Boolean)decide_request.getParameter("accept").getValue(); }
/** * Execute a plan. */ public void body() { IComponentDescription desc = (IComponentDescription)getParameter("description").getValue(); ISearchConstraints constraints = (ISearchConstraints)getParameter("constraints").getValue(); boolean remote = getParameter("remote").getValue()!=null? ((Boolean)getParameter("remote").getValue()).booleanValue(): false; IFuture ret = ((IComponentManagementService)getServiceContainer().getRequiredService("cms").get(this)) .searchComponents(desc, constraints, remote); IComponentDescription[] result = (IComponentDescription[])ret.get(this); for(int i=0; i<result.length; i++) getParameterSet("result").addValue(result[i]); }
/** * Handle the ping request. */ public void body() { getParameter("result").setValue(getBeliefbase().getBelief("ping_answer").getFact()); } }
/** * 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()}; }
/** * Plan body. */ public void body() { // System.out.println("searching: "+getComponentName()); // Todo: support other parameters!? IDFComponentDescription desc = (IDFComponentDescription)getParameter("description").getValue(); ISearchConstraints con = (ISearchConstraints)getParameter("constraints").getValue(); boolean remote = getParameter("remote").getValue()!=null? ((Boolean)getParameter("remote").getValue()).booleanValue(): false; // todo: support remote search (search on all DFs on remote platforms also). if(remote) throw new UnsupportedOperationException("Remote DF search not yet implemented."); IFuture ret = ((IDF)getServiceContainer().getRequiredService("df").get(this)).search(desc, con); IDFComponentDescription[] result = (IDFComponentDescription[])ret.get(this); getParameterSet("result").addValues(result); } }