HighLevelActionSequence.java
Go to the documentation of this file.
00001 /****************************************************************
00002  *
00003  * Copyright (c) 2011, 2012
00004  *
00005  * School of Engineering, Cardiff University, UK
00006  *
00007  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00008  *
00009  * Project name: srs EU FP7 (www.srs-project.eu)
00010  * ROS stack name: srs
00011  * ROS package name: srs_knowledge
00012  * Description: 
00013  *                                                              
00014  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00015  *
00016  * @author Ze Ji, email: jiz1@cf.ac.uk
00017  *
00018  * Date of creation: Oct 2011:
00019  * ToDo: 
00020  *
00021  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022  *
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions are met:
00025  *
00026  *       * Redistributions of source code must retain the above copyright
00027  *         notice, this list of conditions and the following disclaimer.
00028  *       * Redistributions in binary form must reproduce the above copyright
00029  *         notice, this list of conditions and the following disclaimer in the
00030  *         documentation and/or other materials provided with the distribution.
00031  *       * Neither the name of the school of Engineering, Cardiff University nor 
00032  *         the names of its contributors may be used to endorse or promote products 
00033  *         derived from this software without specific prior written permission.
00034  *
00035  * This program is free software: you can redistribute it and/or modify
00036  * it under the terms of the GNU Lesser General Public License LGPL as 
00037  * published by the Free Software Foundation, either version 3 of the 
00038  * License, or (at your option) any later version.
00039  * 
00040  * This program is distributed in the hope that it will be useful,
00041  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00042  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00043  * GNU Lesser General Public License LGPL for more details.
00044  * 
00045  * You should have received a copy of the GNU Lesser General Public 
00046  * License LGPL along with this program. 
00047  * If not, see <http://www.gnu.org/licenses/>.
00048  *
00049  ****************************************************************/
00050 
00051 package org.srs.srs_knowledge.task;
00052 
00053 import java.io.*;
00054 import java.util.StringTokenizer;
00055 import java.util.ArrayList;
00056 import java.util.HashMap;
00057 import java.util.Set;
00058 import ros.pkg.srs_knowledge.msg.*;
00059 import ros.pkg.geometry_msgs.msg.Pose2D;
00060 
00061 import org.srs.srs_knowledge.task.*;
00062 import org.srs.srs_knowledge.knowledge_engine.*;
00063 
00064 import com.hp.hpl.jena.rdf.model.*;
00065 import com.hp.hpl.jena.query.QueryExecutionFactory;
00066 import com.hp.hpl.jena.query.ResultSet;
00067 import com.hp.hpl.jena.query.QueryExecution;
00068 import com.hp.hpl.jena.query.QuerySolution;
00069 import com.hp.hpl.jena.ontology.Individual;
00070 
00071 public class HighLevelActionSequence {
00072     public HighLevelActionSequence() {
00073         indOfCurrent = 0;
00074     }
00075 
00076     public void appendHighLevelAction(HighLevelActionUnit actUnit) {
00077         highLevelActionList.add(actUnit);
00078     }
00079     
00080     public int getSizeOfHighLevelActionList() {
00081         return highLevelActionList.size();
00082     }
00083     
00084     public boolean hasNextHighLevelActionUnit() {
00085         if(indOfCurrent + 1 < getSizeOfHighLevelActionList() && indOfCurrent + 1 >= 0) { 
00086             return true;
00087         }
00088         else {
00089             return false;
00090         }
00091     }
00092 
00093     public HighLevelActionUnit getNextHighLevelActionUnit() {
00094         HighLevelActionUnit ha;
00095         //System.out.println("++++++++ >>   " + indOfCurrent + "   SIZE: " + highLevelActionList.size());
00096         try{ 
00097             ha = highLevelActionList.get(indOfCurrent + 1);
00098             indOfCurrent = indOfCurrent + 1;
00099         }
00100         catch(NullPointerException ne) {
00101             System.out.println(ne.getMessage());
00102             return null;
00103         }
00104         return ha;
00105     }
00106     
00107     public HighLevelActionUnit getCurrentHighLevelActionUnit() {
00108         try{ 
00109             return highLevelActionList.get(indOfCurrent);
00110         }
00111         catch(Exception ne) {
00112             System.out.println(ne.getMessage());
00113             return null;
00114         }
00115     }
00116     
00117     public boolean shiftToNextActionUnit() {
00118         HighLevelActionUnit ha;
00119         if((indOfCurrent + 1 )< highLevelActionList.size()) {
00120             indOfCurrent++;
00121             return true;
00122         }  
00123         return false;
00124     }
00125 
00126     public void setParameter(String key, Object value) {
00127         parameters.put(key, value);
00128     }
00129 
00130     public Object getParameter(String key) {
00131         return parameters.get(key);
00132     }
00133 
00134     public Set<String> parametersSet() {
00135         return (Set<String>)parameters.keySet();
00136     }
00137 
00138     protected int indOfCurrent;
00139     
00140     protected ArrayList<HighLevelActionUnit> highLevelActionList = new ArrayList<HighLevelActionUnit>();
00141 
00142     protected HashMap<String, Object> parameters = new HashMap<String, Object>();
00143 }


srs_knowledge
Author(s): Ze Ji
autogenerated on Sun Jan 5 2014 12:03:28