本文整理了Java中jadex.commons.future.Future.get()
方法的一些代码示例,展示了Future.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.get()
方法的具体详情如下:
包路径:jadex.commons.future.Future
类名称:Future
方法名:get
[英]Get the result - blocking call.
[中]获取结果-阻塞调用。
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Get the result - blocking call.
* @param timeout The timeout in millis.
* @return The future result.
*/
public E get(long timeout)
{
// Default for realtime is false because normally waits should
// use the kind of wait of the internal clock. Outbound calls
// might use explicitly realtime to avoid immediate simulation timeouts.
return get(timeout, false);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Get the result - blocking call.
* @param realtime Flag, if wait should be realtime (in constrast to simulation time).
* @return The future result.
*/
public E get(boolean realtime)
{
return get(NONE);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Get the result - blocking call.
* @return The future result.
*/
public E get()
{
// It is a critical point whether to use NONE or UNSET here
// NONE is good for Jadex service calls which automatically terminate after a timeout,
// problem is with non-Jadex calls which could block infinitely
// UNSET is not good for Jadex calls, because the service call and the get() call could use different timeouts.
// For non-Jadex calls this behavior avoids ever blocking calls and is good.
//return get(UNSET);
return get(NONE);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
public Mood setSlogan(final String slogan)
{
final Future<Mood> ret = new Future<Mood>();
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
calls.add(ret);
slogantf.setText(""+slogan);
}
});
return ret.get();
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-kernel-bdiv3
/**
* Wait for ever (is aborted on goal success/failure).
*/
public void waitForEver()
{
checkNotInAtomic();
Future<Void> ret = new Future<Void>();
ret.get();
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
// System.out.println("Pickup plan: "+getAgentName()+" "+getReason());
IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("env").getFact();
// todo: garbage as parameter?
Map<String, Object> params = new HashMap<String, Object>();
params.put(ISpaceAction.ACTOR_ID, getComponentDescription());
Future<Boolean> fut = new Future<Boolean>();
env.performSpaceAction("pickup", params, new DelegationResultListener<Boolean>(fut));
Boolean res = fut.get();
if(!res.booleanValue())
fail();
// System.out.println("pickup plan end");
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
/**
* The plan body.
*/
@PlanBody
public void body()
{
// System.out.println("Pickup plan: "+agent.getAgent().getAgentName());
IEnvironmentSpace env = agent.getEnvironment();
// todo: garbage as parameter?
Future<Boolean> fut = new Future<Boolean>();
DelegationResultListener<Boolean> lis = new DelegationResultListener<Boolean>(fut, true);
Map<String, Object> params = new HashMap<String, Object>();
params.put(ISpaceAction.ACTOR_ID, agent.getAgent().getComponentDescription());
env.performSpaceAction("pickup", params, lis); // todo: garbage as parameter?
Boolean done = fut.get();
if(!done.booleanValue())
throw new PlanFailureException();
// todo: handle result
// if(!((Boolean)srl.waitForResult()).booleanValue())
// fail();
// System.out.println("pickup plan end");
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-micro
/**
* Block until the given time has passed.
*/
public IFuture<Void> block(long millis)
{
Future<Void> ret = new Future<Void>();
if(millis>0)
{
agent.getComponentFeature(IExecutionFeature.class).waitForDelay(millis).get();
ret.setResult(null);
}
else
{
// do not set result at all and block forever
ret.get();
}
return ret;
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
// System.out.println("Burn plan activated!");
IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("env").getFact();
// Pickup the garbarge.
IGoal pickup = createGoal("pick");
dispatchSubgoalAndWait(pickup);
Map<String, Object> params = new HashMap<String, Object>();
params.put(ISpaceAction.ACTOR_ID, getComponentDescription());
Future<Void> fut = new Future<Void>();
env.performSpaceAction("burn", params, new DelegationResultListener<Void>(fut));
fut.get();
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
/**
* The plan body.
*/
@PlanBody
public void body()
{
// System.out.println("Burn plan activated!");
IEnvironmentSpace env = burner.getEnvironment();
// Pickup the garbarge.
Pick pickup = burner.new Pick();
rplan.dispatchSubgoal(pickup).get();
Future<Void> fut = new Future<Void>();
DelegationResultListener<Void> lis = new DelegationResultListener<Void>(fut, true);
Map<String, Object> params = new HashMap<String, Object>();
params.put(ISpaceAction.ACTOR_ID, burner.getAgent().getComponentDescription());
env.performSpaceAction("burn", params, lis);
fut.get();
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
*
*/
public void body()
{
Future<Void> ret = new Future<Void>();
int target = ((Integer)getBeliefbase().getBelief("target").getFact()).intValue();
int money = ((Integer)getBeliefbase().getBelief("money").getFact()).intValue();
// Create a subgoal for each euro to get
CounterResultListener<Void> lis = new CounterResultListener<Void>(target-money, new DelegationResultListener<Void>(ret));
for(int i=0; i<target-money; i++)
{
createOneEuroSubgoal().addResultListener(lis);
}
ret.get();
// waitForEver();
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The body method.
*/
public void body()
{
TestReport tr = new TestReport("#1", "Testing waitForResult().");
Future<Object> listener = new Future<Object>();
getBeliefbase().getBelief("listener").setFact(listener);
Object result = listener.get();
if("success".equals(result))
tr.setSucceeded(true);
else
tr.setFailed("Wrong result received: "+result);
getBeliefbase().getBeliefSet("testcap.reports").addFact(tr);
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
// System.out.println("MoveToLocation: "+getComponentIdentifier());
ISpaceObject myself = (ISpaceObject)getBeliefbase().getBelief("myself").getFact();
IVector3 dest = (IVector3)getParameter("destination").getValue();
Map<String, Object> props = new HashMap<String, Object>();
props.put(MoveTask.PROPERTY_DESTINATION, dest);
props.put(MoveTask.PROPERTY_SCOPE, getScope().getExternalAccess());
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(getPlanElement()));
IEnvironmentSpace space = (IEnvironmentSpace)getBeliefbase().getBelief("environment").getFact();
Object taskid = space.createObjectTask(MoveTask.PROPERTY_TYPENAME, props, myself.getId());
// move = new MoveTask(dest, res, getExternalAccess());
// myself.addTask(move);
Future<Void> fut = new Future<Void>();
space.addTaskListener(taskid, myself.getId(), new DelegationResultListener<Void>(fut));
fut.get();
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
// System.out.println("MoveToLocation: "+getComponentIdentifier());
ISpaceObject myself = (ISpaceObject)getBeliefbase().getBelief("myself").getFact();
IVector2 dest = (IVector2)getParameter("destination").getValue();
Map<String, Object> props = new HashMap<String, Object>();
props.put(MoveTask.PROPERTY_DESTINATION, dest);
props.put(MoveTask.PROPERTY_SCOPE, getScope().getExternalAccess());
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(getPlanElement()));
IEnvironmentSpace space = (IEnvironmentSpace)getBeliefbase().getBelief("environment").getFact();
Object rtaskid = space.createObjectTask(RotationTask.PROPERTY_TYPENAME, props, myself.getId());
Future<Void> ret = new Future<Void>();
space.addTaskListener(rtaskid, myself.getId(), new DelegationResultListener<Void>(ret));
ret.get();
Object mtaskid = space.createObjectTask(MoveTask.PROPERTY_TYPENAME, props, myself.getId());
ret = new Future<Void>();
space.addTaskListener(mtaskid, myself.getId(), new DelegationResultListener<Void>(ret));
ret.get();
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
ISpaceObject waste = (ISpaceObject)getParameter("waste").getValue();
// Move to the waste position when necessary
// getLogger().info("Moving to waste!");
IGoal moveto = createGoal("achievemoveto");
IVector2 location = (IVector2)waste.getProperty(Space2D.PROPERTY_POSITION);
moveto.getParameter("location").setValue(location);
dispatchSubgoalAndWait(moveto);
IEnvironmentSpace env = (IEnvironmentSpace)getBeliefbase().getBelief("environment").getFact();
Map<String, Object> params = new HashMap<String, Object>();
params.put(ISpaceAction.ACTOR_ID, getComponentDescription());
params.put(ISpaceAction.OBJECT_ID, getParameter("waste").getValue());
Future<Void> fut = new Future<Void>();
env.performSpaceAction("pickup_waste", params, new DelegationResultListener<Void>(fut));
fut.get();
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
/**
* The plan body.
*/
@PlanBody
public void body()
{
ISpaceObject target = goal.getTarget();
MovementCapability capa = producer.getMoveCapa();
// Move to the target.
Move move = capa.new Move(target.getProperty(Space2D.PROPERTY_POSITION));
rplan.dispatchSubgoal(move).get();
// Produce ore at the target.
Future<Void> fut = new Future<Void>();
DelegationResultListener<Void> lis = new DelegationResultListener<Void>(fut, true);
ISpaceObject myself = capa.getMyself();
Map props = new HashMap();
props.put(ProduceOreTask.PROPERTY_TARGET, target);
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(rplan));
IEnvironmentSpace space = capa.getEnvironment();
Object taskid = space.createObjectTask(ProduceOreTask.PROPERTY_TYPENAME, props, myself.getId());
space.addTaskListener(taskid, myself.getId(), lis);
fut.get();
// System.out.println("Produced ore at target: "+getAgentName()+", "+ore+" ore produced.");
callCarryAgent(target);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
/**
* The plan body.
*/
@PlanBody
public void body()
{
Space2D space = (Space2D)capa.getMoveCapa().getEnvironment();
ISpaceObject myself = capa.getMoveCapa().getMyself();
ISpaceObject disaster = (ISpaceObject)goal.getDisaster();
// Move to disaster location
myself.setProperty("state", "moving_to_disaster");
IVector2 targetpos = DisasterType.getFireLocation(disaster);
Move move = capa.getMoveCapa().new Move(targetpos);
rplan.dispatchSubgoal(move).get();
// Extinguish fire
myself.setProperty("state", "extinguishing_fire");
Map<String, Object> props = new HashMap<String, Object>();
props.put(ExtinguishFireTask.PROPERTY_DISASTER, disaster);
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(rplan));
Object taskid = space.createObjectTask(ExtinguishFireTask.PROPERTY_TYPENAME, props, myself.getId());
Future<Void> fut = new Future<Void>();
DelegationResultListener<Void> lis = new DelegationResultListener<Void>(fut, true);
space.addTaskListener(taskid, myself.getId(), lis);
fut.get();
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
ISpaceObject target = (ISpaceObject)getParameter("target").getValue();
// Move to the target.
IGoal go_target = createGoal("move.move_dest");
go_target.getParameter("destination").setValue(target.getProperty(Space3D.PROPERTY_POSITION));
dispatchSubgoalAndWait(go_target);
// Produce ore at the target.
ISpaceObject myself = (ISpaceObject)getBeliefbase().getBelief("move.myself").getFact();
Map<String, Object> props = new HashMap<String, Object>();
props.put(ProduceOreTask.PROPERTY_TARGET, target);
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(getPlanElement()));
IEnvironmentSpace space = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact();
Object taskid = space.createObjectTask(ProduceOreTask.PROPERTY_TYPENAME, props, myself.getId());
Future<Void> fut = new Future<Void>();
space.addTaskListener(taskid, myself.getId(), new DelegationResultListener<Void>(fut));
fut.get();
// System.out.println("Produced ore at target: "+getAgentName()+", "+ore+" ore produced.");
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
/**
* The plan body.
*/
public void body()
{
ISpaceObject target = (ISpaceObject)getParameter("target").getValue();
// Move to the target.
IGoal go_target = createGoal("move.move_dest");
go_target.getParameter("destination").setValue(target.getProperty(Space2D.PROPERTY_POSITION));
dispatchSubgoalAndWait(go_target);
// Produce ore at the target.
ISpaceObject myself = (ISpaceObject)getBeliefbase().getBelief("move.myself").getFact();
Map<String, Object> props = new HashMap<String, Object>();
props.put(ProduceOreTask.PROPERTY_TARGET, target);
props.put(AbstractTask.PROPERTY_CONDITION, new PlanFinishedTaskCondition(getPlanElement()));
IEnvironmentSpace space = (IEnvironmentSpace)getBeliefbase().getBelief("move.environment").getFact();
Object taskid = space.createObjectTask(ProduceOreTask.PROPERTY_TYPENAME, props, myself.getId());
Future<Void> fut = new Future<Void>();
space.addTaskListener(taskid, myself.getId(), new DelegationResultListener<Void>(fut));
fut.get();
// System.out.println("Produced ore at target: "+getAgentName()+", "+ore+" ore produced.");
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdi
public void body()
{
IComponentManagementService cms = getAgent().getComponentFeature(IRequiredServicesFeature.class)
.searchService(IComponentManagementService.class, RequiredServiceInfo.SCOPE_PLATFORM).get();
Environment en = (Environment)getBeliefbase().getBelief("environment").getFact();
Creature[] creatures = en.getCreatures();
Future<Void> destroyed = new Future<Void>();
IResultListener<Map<String, Object>> lis = new CounterResultListener<Map<String, Object>>(creatures.length, new DelegationResultListener<Void>(destroyed));
for(int i = 0; i < creatures.length; i++)
{
// System.out.println(creatures[i].getAID());
en.removeCreature(creatures[i]);
cms.destroyComponent(creatures[i].getAID()).addResultListener(lis);
}
destroyed.get();
cms.destroyComponent(getScope().getComponentIdentifier().getParent());
}
}
内容来源于网络,如有侵权,请联系作者删除!