KbHitTask.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno    
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00029 
00030 
00034 
00035 
00036 #ifndef __KB_HIT_TASK_H_
00037 #define __KB_HIT_TASK_H_
00038 
00039 #include <Task.h>
00040 #include <TaskFactory.h>
00041 #include <MobileRob.h>
00042 #include <Keyboard.h>
00043 #include <termios.h>
00044 
00045 using namespace MipResources;
00046 
00047 namespace MipTasks{
00048  
00050  /* @{ */
00051  
00052  class KbHitTask : public Task{
00053   private:
00054    static const TaskPlate _plate = KBH_TASK;
00055  #ifndef MIP_PLATFORM_ARM
00056    static const long int  _maxDurSec  = 0,      _maxDurUsec     = 50000;
00057    static const long int  _maxSamplPeriodSec = 1, _maxSamplPeriodUsec = 0;
00058    static const long int  _minSamplPeriodSec = 0, _minSamplPeriodUsec = 50000;
00059  #else
00060    static const long int  _maxDurSec  = 0,      _maxDurUsec     = 20000;
00061    static const long int  _maxSamplPeriodSec = 1, _maxSamplPeriodUsec = 0;
00062    static const long int  _minSamplPeriodSec = 0, _minSamplPeriodUsec = 5000;
00063  #endif
00064    Keyboard* _keyboard; 
00065    
00066    unsigned int _kbhit(Time timeout);
00067    
00068   public:
00070    KbHitTask(ResourcePointers resources,int argc, const char* argv[]);
00071    
00073    ~KbHitTask();
00074    
00076    TaskPlate getPlate() const {
00077     return _plate;
00078    }
00080    Time getMaxDuration(){
00081     return Time(_maxDurSec,_maxDurUsec);
00082    }
00084    Time getMaxSamplPeriod(){
00085     return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00086    }
00088    Time getMinSamplPeriod(){
00089     return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00090    }
00091    
00093    TaskOutputs run();
00094  };
00095  
00096  MIP_REGISTER_STATIC_TASK(KbHitTask)
00097  
00098  
00099  /* @} */
00100  
00101 };// end namespace MipTasks
00102 
00103 #endif
00104 
00105 
00106 
00107 
00108 

Generated on Mon Feb 20 07:01:08 2017 for MIP by  doxygen 1.5.6