SensorAgent.C

Go to the documentation of this file.
00001 /*!@file BeoSub/BeeBrain/SensorAgent.C Sensor Agent superclass         */
00002 // //////////////////////////////////////////////////////////////////// //
00003 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00004 // University of Southern California (USC) and the iLab at USC.         //
00005 // See http://iLab.usc.edu for information about this project.          //
00006 // //////////////////////////////////////////////////////////////////// //
00007 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00008 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00009 // in Visual Environments, and Applications'' by Christof Koch and      //
00010 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00011 // pending; application number 09/912,225 filed July 23, 2001; see      //
00012 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00013 // //////////////////////////////////////////////////////////////////// //
00014 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00015 //                                                                      //
00016 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00017 // redistribute it and/or modify it under the terms of the GNU General  //
00018 // Public License as published by the Free Software Foundation; either  //
00019 // version 2 of the License, or (at your option) any later version.     //
00020 //                                                                      //
00021 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00022 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00023 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00024 // PURPOSE.  See the GNU General Public License for more details.       //
00025 //                                                                      //
00026 // You should have received a copy of the GNU General Public License    //
00027 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00028 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00029 // Boston, MA 02111-1307 USA.                                           //
00030 // //////////////////////////////////////////////////////////////////// //
00031 //
00032 // Primary maintainer for this file: Michael Montalbo <montalbo@usc.edu>
00033 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/BeoSub/BeeBrain/SensorAgent.C $
00034 // $Id: SensorAgent.C 8623 2007-07-25 17:57:51Z rjpeters $
00035 //
00036 //////////////////////////////////////////////////////////////////////////
00037 
00038 #include "rutz/shared_ptr.h"
00039 #include "Util/log.H"
00040 
00041 #include "BeoSub/BeeBrain/SensorAgent.H"
00042 
00043 // ######################################################################
00044 // Constructor
00045 SensorAgent::SensorAgent(std::string name) : Agent(name)
00046 { }
00047 
00048 // ######################################################################
00049 // Messages
00050 void SensorAgent::msgFindAndTrackObject
00051 (uint oceanObjectId,
00052  OceanObject::OceanObjectType oceanObjectType,
00053  DataTypes dataType)
00054 {
00055   stateChanged();
00056   //Create a new Job
00057   Job* j = new Job();
00058   rutz::shared_ptr<OceanObject> oceanObject(new OceanObject());
00059   oceanObject->setId(oceanObjectId);
00060   oceanObject->setType(oceanObjectType);
00061   j->oceanObject = oceanObject;
00062   j->dataType = dataType;
00063   j->status = NOT_STARTED;
00064   //Add it to the queue of objects to be looked for
00065   itsJobs.push_back(j);
00066 }
00067 
00068 // ######################################################################
00069 void SensorAgent::msgStopLookingForObject
00070 ( uint oceanObjectId,
00071   DataTypes dataType)
00072 {
00073   stateChanged();
00074   // Iterate through all the jobs and find the object which is to be ignored
00075   for(itsJobsItr = itsJobs.begin(); itsJobsItr != itsJobs.end(); ++itsJobsItr)
00076   {
00077     rutz::shared_ptr<OceanObject> currentOceanObject = (*itsJobsItr)->oceanObject;
00078     DataTypes currentDataType = (*itsJobsItr)->dataType;
00079     Job* currentJob = *itsJobsItr;
00080     // When found, set status so as to ignore that job from now on
00081     if(currentOceanObject->getId() == oceanObjectId && currentDataType == dataType)
00082     {
00083       currentJob->status = IGNORE;
00084     }
00085   }
00086 }
00087 
00088 // ######################################################################
00089 // Dummy scheduler. Descendent agents implement something meaningful here
00090 // bool SensorAgent::pickAndExecuteAnAction()
00091 // {
00092 //   return false;
00093 // }
00094 
00095 // ######################################################################
00096 // Actions
00097 void SensorAgent::cleanJobs()
00098 {
00099   itsJobsItr = itsJobs.begin();
00100 
00101   while(itsJobsItr != itsJobs.end())
00102   {
00103     Job* currentJob = *itsJobsItr;
00104     // If a job is marked as ignore, remove it from the job list
00105     if(currentJob->status == IGNORE)
00106       {
00107         LINFO("Removing Ocean Object: %d from Job list", currentJob->oceanObject->getId());
00108         itsJobsItr = itsJobs.erase(itsJobsItr);
00109       }
00110     else
00111       {
00112         itsJobsItr++;
00113       }
00114   }
00115 }
00116 
00117 // Misc
00118 
00119 // void SensorAgent::setPreFrontalCortex(PreFrontalCortex* c)
00120 // {
00121 //   itsCortex = c;
00122 // }
00123 
00124 // ######################################################################
00125 uint SensorAgent::getNumJobs()
00126 {
00127   return itsJobs.size();
00128 }
00129 
00130 // ######################################################################
00131 /* So things look consistent in everyone's emacs... */
00132 /* Local Variables: */
00133 /* indent-tabs-mode: nil */
00134 /* End: */
Generated on Sun May 8 08:40:19 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3