Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef FILEDESCRIPTOR_ACTIVITY_HPP
00040 #define FILEDESCRIPTOR_ACTIVITY_HPP
00041
00042 #include "../Activity.hpp"
00043 #include <set>
00044
00045 namespace RTT { namespace extras {
00046
00103 class RTT_API FileDescriptorActivity : public Activity
00104 {
00105 std::set<int> m_watched_fds;
00106 bool m_running;
00107 int m_interrupt_pipe[2];
00108 int m_timeout_us;
00109 Seconds m_period;
00110
00111 mutable RTT::os::Mutex m_lock;
00112 fd_set m_fd_set;
00113 fd_set m_fd_work;
00114 bool m_has_error;
00115 bool m_has_timeout;
00116
00117 static const char CMD_BREAK_LOOP = 0;
00118 static const char CMD_TRIGGER = 1;
00119 static const char CMD_UPDATE_SETS = 2;
00120
00124 void triggerUpdateSets();
00125
00126 public:
00136 FileDescriptorActivity(int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00137
00148 FileDescriptorActivity(int scheduler, int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00149
00161 FileDescriptorActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00162
00175 FileDescriptorActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity,
00176 base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
00177
00178 virtual ~FileDescriptorActivity();
00179
00180 bool isRunning() const;
00181
00183 virtual Seconds getPeriod() const;
00184
00186 virtual bool setPeriod(Seconds period);
00187
00198 void watch(int fd);
00199
00204 void unwatch(int fd);
00205
00207 void clearAllWatches();
00208
00211 bool isWatched(int fd) const;
00212
00219 bool isUpdated(int fd) const;
00220
00228 bool hasTimeout() const;
00229
00237 bool hasError() const;
00238
00244 void setTimeout(int timeout);
00245
00251 void setTimeout_us(int timeout_us);
00252
00256 int getTimeout() const;
00257
00261 int getTimeout_us() const;
00262
00263 virtual bool start();
00264 virtual void loop();
00265 virtual bool breakLoop();
00266 virtual bool stop();
00267
00271 virtual void step();
00272
00276 virtual bool trigger();
00277 };
00278 }}
00279
00280 #endif