本文整理汇总了Java中eis.exceptions.PerceiveException类的典型用法代码示例。如果您正苦于以下问题:Java PerceiveException类的具体用法?Java PerceiveException怎么用?Java PerceiveException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PerceiveException类属于eis.exceptions包,在下文中一共展示了PerceiveException类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAllPerceptsFromEntity
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@Override
protected LinkedList<Percept> getAllPerceptsFromEntity(String ent) throws PerceiveException, NoEnvironmentException {
LinkedList<Percept> eisPer = new LinkedList<Percept>();
List<Literal> lper = jasonEnv.getPercepts(ent);
if (lper == null) { // no changes in the perception for ent
lper = previousPerception.get(ent);
} else {
lper = previousPerception.put(ent, lper);
}
if (lper != null)
for (Literal jasonPer: lper)
eisPer.add( Translator.literalToPercept( jasonPer ));
//System.out.println("perceptions for "+ent+" are "+eisPer);
return eisPer;
}
开发者ID:jason-lang,项目名称:apps,代码行数:18,代码来源:JasonAdapter.java
示例2: gatherPercepts
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Gets all percepts for a certain agent for a specified list of entities
*
* @param agent
* the agent's name
* @param associatedEntities
* the set of attached entities
* @param entities
* the entities we want percepts for
* @return Returns a map with all percepts
* @throws PerceiveException
* unable to get percepts because the entity does not belong to
* this agent
*/
Map<String, Collection<Percept>> gatherPercepts(String agent, Set<String> associatedEntities, String... entities)
throws PerceiveException {
if (entities.length == 0) {
// No entities selected, get percepts for all associated entities
entities = associatedEntities.toArray(new String[associatedEntities.size()]);
}
Map<String, Collection<Percept>> perceptsMap = new HashMap<>(entities.length);
for (String entity : entities) {
if (!associatedEntities.contains(entity)) {
throw new PerceiveException(
"Entity \"" + entity + "\" has not been associated with the agent \"" + agent + "\".");
}
perceptsMap.put(entity, gatherPercepts(entity));
}
return perceptsMap;
}
开发者ID:eishub,项目名称:BW4T,代码行数:31,代码来源:RemoteEnvironment.java
示例3: getAllPerceptsFromEntity
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Get all percepts for a certain entity, is passed through the server.
*
* @param entity
* The entity for which the percepts are requested.
* @param env
* . The remote environment
* @return The list of received percepts.
* @throws PerceiveException
* The NoEnvironmentException is thrown if an attempt to perform an action or to retrieve percepts has
* failed.
*/
public static List<Percept> getAllPerceptsFromEntity(String entity, RemoteEnvironment env) throws PerceiveException {
final BW4TClient client = env.getClient();
if (client == null) {
return new ArrayList<>(0);
}
try {
if (entity.endsWith("gui")) {
entity = entity.substring(0, entity.length() - 4);
}
final List<Percept> percepts = client.getAllPerceptsFromEntity(entity);
ClientController cc = env.getEntityController(entity);
if (cc != null) {
percepts.addAll(cc.getToBePerformedAction());
}
return percepts;
} catch (RemoteException e) {
throw env.environmentSuddenDeath(e);
}
}
开发者ID:eishub,项目名称:BW4T,代码行数:32,代码来源:PerceptsHandler.java
示例4: getPercepts
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Creates new percepts by calling the given method on the entity.
*
* @param entity
* the entity to get the percept from.
* @param method
* the method to invoke on the entity which must be annotated
* with {@link AsPercept}.
* @return The percepts that were generated by invoking the method on the
* entity.
* @throws PerceiveException
* If the percepts couldn't be retrieved.
*/
private List<Percept> getPercepts(Method method) throws PerceiveException {
// list of new objects for the percepts
List<Object> perceptObjects = new ArrayList<Object>();
// Optimization, don't call methods for once percepts if they have been
// called before.
AsPercept annotation = method.getAnnotation(AsPercept.class);
Filter.Type filter = annotation.filter();
if (filter != Filter.Type.ONCE || previousPercepts.get(method) == null) {
perceptObjects = getPerceptObjects(method);
}
List<Percept> percepts = translatePercepts(method, perceptObjects);
return percepts;
}
开发者ID:eishub,项目名称:eis,代码行数:30,代码来源:DefaultPerceptHandler.java
示例5: extractMultipleParameters
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Handle multiple arguments. The parameter list must be a list containing
* just one {@link ParameterList}. Returns a list with all elements in that
* {@link ParameterList}.
*
* @param parameters
* @return
* @throws PerceiveException
* if parameters is not the right format.
*/
private Parameter[] extractMultipleParameters(Parameter[] parameters) throws PerceiveException {
if (parameters.length == 1 && parameters[0] instanceof ParameterList) {
// special case where the top set is the set of arguments
// for function
ParameterList params = (ParameterList) parameters[0];
parameters = new Parameter[params.size()];
for (int i = 0; i < params.size(); i++) {
parameters[i] = params.get(i);
}
} else {
throw new PerceiveException(
"multipleArguments parameter is set and therefore expecting a set but got " + parameters);
}
return parameters;
}
开发者ID:eishub,项目名称:eis,代码行数:26,代码来源:AbstractPerceptHandler.java
示例6: getAllPercepts
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@Override
public final LinkedList<Percept> getAllPercepts() throws PerceiveException {
LinkedList<Percept> percepts = new LinkedList<Percept>();
Map<Method, Object> batchPerceptObjects;
batchPerceptObjects = allPercepProvider.getAllPercepts();
for (Entry<Method, Object> entry : batchPerceptObjects.entrySet()) {
Method method = (Method) entry.getKey();
Object perceptObject = entry.getValue();
List<Object> perceptObjects = unpackPerceptObject(method,
perceptObject);
List<Percept> translatedPercepts = translatePercepts(method,
perceptObjects);
percepts.addAll(translatedPercepts);
}
return percepts;
}
开发者ID:eishub,项目名称:eis,代码行数:23,代码来源:AllPerceptPerceptHandler.java
示例7: testGetAllPercepts
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@Test
public void testGetAllPercepts() throws PerceiveException {
LinkedList<Percept> percepts = handler.getAllPercepts();
assertAllPerceptsReceived(percepts);
percepts = handler.getAllPercepts();
assertPartialPerceptsReceived(percepts);
// Check, third time we should still get same percepts?
// percepts = handler.getAllPercepts();
// assertPartialPerceptsReceived(percepts);
handler.reset();
percepts = handler.getAllPercepts();
assertAllPerceptsReceived(percepts);
}
开发者ID:eishub,项目名称:eis,代码行数:18,代码来源:PerceptHandlerTest.java
示例8: getAllPercepts
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Retrieves all percepts for this entity.
* If scheduling is enabled, the method blocks until a new action id, i.e. new percepts, are received
* or the configured timeout is reached.
* If queued is enabled, scheduling is overridden. Also, if queued is enabled, this method has to be called
* repeatedly, as only one collection of percepts is removed from the queue with each call (until an empty list
* is returned).
* @return all percepts for this entity
* @throws PerceiveException if timeout configured and occurred
*/
LinkedList<Percept> getAllPercepts() throws PerceiveException{
if (scheduling && !queued) {
// wait for new action id or timeout
long startTime = System.currentTimeMillis();
while (currentActionId <= lastUsedActionIdPercept || currentActionId == -1 ) {
try {
Thread.sleep(10);
} catch (InterruptedException ignored) {}
if (System.currentTimeMillis() - startTime >= timeout) {
throw new PerceiveException("timeout. no valid action-id available in time");
}
}
lastUsedActionIdPercept = currentActionId;
}
if(!queued){
//return all percepts
LinkedList<Percept> ret = new LinkedList<>();
ret.addAll(simStartPercepts);
ret.addAll(requestActionPercepts);
ret.addAll(simEndPercepts);
ret.addAll(byePercepts);
if (useIILang) log(ret.toString());
return ret;
}
else{
//return only the first queued elements
return perceptsQueue.peek() != null? new LinkedList<>(perceptsQueue.poll()) : new LinkedList<>();
}
}
开发者ID:agentcontest,项目名称:massim,代码行数:41,代码来源:EISEntity.java
示例9: getAllPerceptsFromEntity
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@Override
protected LinkedList<Percept> getAllPerceptsFromEntity(String entity)
throws PerceiveException, NoEnvironmentException {
Entity e = entityNamesToObjects.get(entity);
if ( e.isConnected() == false ) {
throw new PerceiveException("no valid connection");
}
LinkedList<Percept> percepts = e.getAllPercepts();
return percepts;
}
开发者ID:jason-lang,项目名称:apps,代码行数:15,代码来源:EnvironmentInterface.java
示例10: receiving
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@INTERNAL_OPERATION
void receiving() throws JasonException {
lastStep = -1;
Collection<Percept> previousPercepts = new ArrayList<Percept>();
while (receiving) {
await_time(100);
for (String agent: agentIds.keySet()) {
try {
Collection<Percept> percepts = ei.getAllPercepts(agent).get(agentToEntity.get(agent));
populateTeamArtifact(percepts);
//logger.info("***"+percepts);
if (percepts.isEmpty())
break;
int currentStep = getCurrentStep(percepts);
if (lastStep != currentStep) { // only updates if it is a new step
lastStep = currentStep;
filterLocations(agent, percepts);
//logger.info("Agent "+agent);
updatePerception(agent, previousPercepts, percepts);
previousPercepts = percepts;
}
} catch (PerceiveException | NoEnvironmentException e) {
e.printStackTrace();
}
}
}
}
开发者ID:smart-pucrs,项目名称:mapc2016-pucrs,代码行数:29,代码来源:EISArtifact.java
示例11: testGetAllPerceptsFromEntity
import eis.exceptions.PerceiveException; //导入依赖的package包/类
@Test
public void testGetAllPerceptsFromEntity() throws PerceiveException, NotBoundException, IOException {
BW4TClient bw4tClient = new BW4TClient(remoteEnvironment);
HumanAgent humanAgent = new HumanAgent("agentID", remoteEnvironment);
NewMap newMap = new NewMap();
bw4tClient.useMap(newMap);
when(remoteEnvironment.getClient()).thenReturn(bw4tClient);
BW4TClientGUI bw4tClientGUI = new BW4TClientGUI(remoteEnvironment, "entityID", humanAgent);
String entity = "test";
when(remoteEnvironment.getEntityController(entity)).thenReturn(bw4tClientGUI.getController());
PerceptsHandler.getAllPerceptsFromEntity(entity, remoteEnvironment);
}
开发者ID:eishub,项目名称:BW4T,代码行数:14,代码来源:PerceptsHandlerTest.java
示例12: getAt
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept for navpoints the robot is at. Send on change. If robot is in a
* {@link Zone}, that zone name is returned. If not, the nearest
* {@link Corridor} name is returned.
*
* @return a list of blockID
* @throws PerceiveException
*/
@AsPercept(name = "at", multiplePercepts = false, filter = Filter.Type.ON_CHANGE)
public String getAt() throws PerceiveException {
Zone navpt = ZoneLocator.getNearestZone(ourRobot.getLocation());
if (navpt == null) {
throw new PerceiveException(
"perceiving 'at' percept failed, because map has no suitable navpoint for position "
+ ourRobotLocation);
}
return navpt.getName();
}
开发者ID:eishub,项目名称:BW4T,代码行数:20,代码来源:RobotEntity.java
示例13: heldBy
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept if the e-Partner was dropped.
*
* @return id of holder
* @throws PerceiveException
*/
@AsPercept(name = "heldBy", multiplePercepts = false, filter = Filter.Type.ALWAYS)
public long heldBy() throws PerceiveException {
if (ourEPartner.getTypeList().contains(ViewEPartner.FORGET_ME_NOT) && ourEPartner.getHolder() != null) {
return ourEPartner.getHolder().getId();
}
return -1;
}
开发者ID:eishub,项目名称:BW4T,代码行数:14,代码来源:EPartnerEntity.java
示例14: isTaken
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept if the epartner is taken, so other bots won't pick it up if a bot has forgot it.
*
* @return The epartner id.
* @throws PerceiveException
*/
@AsPercept(name = "isTaken", multiplePercepts = false, filter = Filter.Type.ALWAYS)
public long isTaken() throws PerceiveException {
if (ourEPartner.getTypeList().contains(ViewEPartner.FORGET_ME_NOT) && ourEPartner.getHolder() != null) {
return ourEPartner.getId();
}
return -1;
}
开发者ID:eishub,项目名称:BW4T,代码行数:14,代码来源:EPartnerEntity.java
示例15: leftBehind
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept if the epartner is left behind, so the epartner knows when to message the holder.
*
* @return 1 if it was left behind, 0 if it's still held.
* @throws PerceiveException
*/
@AsPercept(name = "leftBehind", multiplePercepts = false, filter = Filter.Type.ON_CHANGE)
public int leftBehind() throws PerceiveException {
if (ourEPartner.getTypeList().contains(ViewEPartner.FORGET_ME_NOT) && ourEPartner.getHolder() == null) {
return 1;
}
return 0;
}
开发者ID:eishub,项目名称:BW4T,代码行数:14,代码来源:EPartnerEntity.java
示例16: getAt
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept for navpoints the robot is at. Send on change. If robot is in a {@link Zone}, that zone name is returned.
* If not, the nearest {@link Corridor} name is returned.
*
* @return a list of blockID
* @throws PerceiveException
*/
@AsPercept(name = "at", multiplePercepts = false, filter = Filter.Type.ON_CHANGE)
public String getAt() throws PerceiveException {
if (ourEPartner.getTypeList().contains(ViewEPartner.GPS)) {
Zone navpt = ZoneLocator.getNearestZone(ourEPartner.getLocation());
if (navpt == null) {
throw new PerceiveException(
"perceiving 'at' percept failed, because map has no suitable navpoint for position "
+ ourEPartnerLocation);
}
return navpt.getName();
}
return "";
}
开发者ID:eishub,项目名称:BW4T,代码行数:22,代码来源:EPartnerEntity.java
示例17: getRooms
import eis.exceptions.PerceiveException; //导入依赖的package包/类
/**
* Percept for the places in the world. Send at the beginning
*
* @return Rooms of the epartner
* @throws PerceiveException
*/
@AsPercept(name = "place", multiplePercepts = true, filter = Filter.Type.ONCE)
public List<String> getRooms() throws PerceiveException {
List<String> places = new LinkedList<>();
if (ourEPartner.getTypeList().contains(ViewEPartner.GPS)) {
for (Object o : context.getObjects(Zone.class)) {
Zone zone = (Zone) o;
places.add(zone.getName());
}
}
return places;
}
开发者ID:eishub,项目名称:BW4T,代码行数:19,代码来源:EPartnerEntity.java
注:本文中的eis.exceptions.PerceiveException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论