EmergencyLock.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 
00026 
00027 
00032 
00033 
00037 
00038 
00039 
00040 #ifndef __EMER_LOCK_TASK_H_
00041 #define __EMER_LOCK_TASK_H_
00042 
00043 #include <Task.h>
00044 #include <Resource.h>
00045 #include <MobileRob.h>
00046 #include <SharedMem.h>
00047 
00048 
00049 using namespace MipResources;
00050 
00051 
00052 namespace MipTasks{
00053  
00055  /* @{ */
00056  
00057  
00061  class EmergencyLockSharedMem : public SharedMem{
00062   public:
00064    void initSharedMem(){
00065    }
00066    
00068    bool emergencyLock(){
00069     return _emergencyLock;
00070    }
00071    void setEmergencyLock(){
00072     _emergencyLock = true;
00073    }
00074    void unsetEmergencyLock(){
00075     _emergencyLock = false;
00076    }
00077  };
00078  
00079  
00083  class EmergencyLock : public Task{
00084   private:
00085    static const TaskPlate _plate = EML_TASK;
00086    static const long int  _maxDurSec  = 0,      _maxDurUsec = 5000;
00087    static const long int  _maxSamplPeriodSec = 0, _maxSamplPeriodUsec = 30000;
00088    static const long int  _minSamplPeriodSec = 0, _minSamplPeriodUsec = 10000;
00089    
00090    MobileRob*  _mobileRob;
00091    
00092    EmergencyLockSharedMem* _sharedMem;
00093    
00094  //   bool locked;
00095    
00096   public:
00098    EmergencyLock(ResourcePointers resources,int argc, const char* argv[]){
00099     
00100     _mobileRob = (MobileRob*) ResourceUtilities::macroResFromPlate(resources,MR_INIT,MR_END);
00101     if(_mobileRob == 0){
00102      fatalResourceNotPresent(MR_INIT);
00103     }
00104     
00105     // richiedi una risorsa di tipo SharedMem
00106     _sharedMem = (EmergencyLockSharedMem*) ResourceUtilities::resFromPlate(resources,SHMEM_RES);
00107     if(_sharedMem == 0){
00108      fatalResourceNotPresent(SHMEM_RES);
00109     }
00110     _sharedMem->initSharedMem();
00111     
00112  //    locked = false;
00113    }
00115    ~EmergencyLock(){
00116     cout << "destr FeatExtrTask" << endl;
00117    }
00119    TaskPlate getPlate() const {
00120     return _plate;
00121    }  
00123    Time getMaxDuration(){
00124     return Time(_maxDurSec,_maxDurUsec);
00125    }
00127    Time getMaxSamplPeriod(){
00128     return Time(_maxSamplPeriodSec,_maxSamplPeriodUsec);
00129    }
00131    Time getMinSamplPeriod(){
00132     return Time(_minSamplPeriodSec,_minSamplPeriodUsec);
00133    }
00135    TaskOutputs run();
00136    
00137  };
00138  
00139  /* @} */
00140  
00141 };// end namespace MipTasks
00142 
00143 #endif
00144 
00145 
00146 
00147 

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