monitorTask.h

Go to the documentation of this file.
00001 #ifndef MONITO_TASK_H
00002 #define MONITO_TASK_H
00003 
00013 #include "taskInterface.h"
00014 #include "sdlBase.h"
00015 #include <vector>
00016 #ifdef HAVE_CONFIG_H
00017 #include <config.h>
00018 #endif
00019 #if !HAVE_CONFIG_H || HAVE_LIBSDL
00020 #include <SDL_thread.h>
00021 #endif
00022 #include "runCtrl.h"
00023 
00024 class vmonitor;
00025 class ScreenTask;
00026 
00027 
00031 class MonitorTask : private SDL_Base {
00032   friend class ScreenTask;
00033   friend class URG_Simulator;
00034   friend class mRunCtrl;
00035 
00036   SDL_mutex* mutex;
00037   SDL_Thread* thread;
00038   static std::vector<TaskInterface*> tasks;
00039   static ScreenTask* scr;
00040   bool active;
00041   bool is_pause;
00042   unsigned long pre_total;
00043   unsigned long pre_ticks;
00044   double time_magnify;
00045   static VXV::Position3D bodyPosition;
00046   static RunCtrl* runObj;
00047 
00048   typedef struct {
00049     unsigned long ticks;
00050     SDL_cond* cond;
00051     SDL_mutex* mutex;
00052   } waits_t;
00053   std::vector<waits_t> waits;
00054 
00055   static unsigned long ticks;
00056   static int taskThread(void* args);
00057 
00058 public:
00059   MonitorTask(void);
00060   ~MonitorTask(void);
00061 
00065   void lock(void);
00066 
00070   void unlock(void);
00071 
00079   SDL_cond* setWakeupTicks(unsigned long wait_ticks,
00080                            SDL_cond* wait_cond, SDL_mutex* wait_mutex);
00081 
00087   unsigned long getTicks(void);
00088 
00094   void add(TaskInterface* task);
00095 
00101   void del(TaskInterface* task);
00102 
00106   void pause(void);
00107 
00111   void start(void);
00112 
00118   void setTimeMagnify(double magnify);
00119 
00127   void waitToTicks(unsigned long ticks, SDL_cond* cond, SDL_mutex* wait_mutex);
00128 
00132   void waitOnlyCommand(vmonitor* mon, int monitorMode,
00133                        SDL_cond* cond, SDL_mutex* wait_mutex,
00134                        const char* module, const char* command);
00135 
00136   void setRunObject(RunCtrl* run_obj);
00137 
00138   void setScreenObject(ScreenTask* scr_obj);
00139 
00140   static VXV::Position getRunPosition(void);
00141 };
00142 
00143 #endif /* !MONITO_TASK_H */
00144 

Generated on Mon Apr 13 22:52:03 2009 by  doxygen 1.5.7.1