00001 /*!@file AppDevices/test-GPS.C test GPS driver */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2003 // 00005 // by the University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Nitin Dhavale <dhavale@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppDevices/test-GPS.C $ 00035 // $Id: test-GPS.C 13712 2010-07-28 21:00:40Z itti $ 00036 // 00037 00038 #include "Component/ModelManager.H" 00039 #include "Devices/GPS.H" 00040 00041 //! GPS listener for our test application 00042 class TestGPSlistener { 00043 public: 00044 //! Constructor 00045 TestGPSlistener() { buf = new char[1000]; }; 00046 00047 //! Destructor 00048 virtual ~TestGPSlistener() { delete [] buf; }; 00049 00050 //! Called when data is received 00051 virtual void newData(const GPSdata& data) 00052 { data.toString(buf, 1000); LINFO("%s", buf); }; 00053 00054 private: 00055 char *buf; 00056 }; 00057 00058 00059 //! This program tests the GPS driver, using its listener hookup mode 00060 int main(const int argc, const char **argv) 00061 { 00062 // instantiate a model manager: 00063 ModelManager manager("GPS Driver Tester"); 00064 00065 // Instantiate our various ModelComponents: 00066 nub::soft_ref<GPS> gps(new GPS(manager)); 00067 rutz::shared_ptr<TestGPSlistener> lis(new TestGPSlistener()); 00068 rutz::shared_ptr<GPSlistener> lis2; lis2.dynCastFrom(lis); 00069 00070 gps->setListener(lis2); 00071 00072 manager.addSubComponent(gps); 00073 00074 // Parse command-line: 00075 if (manager.parseCommandLine(argc, argv, "[device]", 0, 1) == false) 00076 return(1); 00077 00078 // do post-command-line configs: 00079 if (manager.numExtraArgs() > 0) 00080 gps->setModelParamString("GPSserialDevName", 00081 manager.getExtraArg(0), MC_RECURSE); 00082 00083 // let's get all our ModelComponent instances started: 00084 manager.start(); 00085 00086 // our main loop is a no-op, the thread and event-based listener do 00087 // all the work: 00088 while(1) sleep(100); 00089 00090 // end of story: 00091 manager.stop(); 00092 return 0; 00093 } 00094 00095 00096 // ###################################################################### 00097 /* So things look consistent in everyone's emacs... */ 00098 /* Local Variables: */ 00099 /* indent-tabs-mode: nil */ 00100 /* End: */ 00101