Libbarrett
1.2.4
|
00001 /* 00002 Copyright 2009, 2010 Barrett Technology <support@barrett.com> 00003 00004 This file is part of libbarrett. 00005 00006 This version of libbarrett is free software: you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License as 00008 published by the Free Software Foundation, either version 3 of the 00009 License, or (at your option) any later version. 00010 00011 This version of libbarrett is distributed in the hope that it will be 00012 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this version of libbarrett. If not, see 00018 <http://www.gnu.org/licenses/>. 00019 00020 Further, non-binding information about licensing is available at: 00021 <http://wiki.barrett.com/libbarrett/wiki/LicenseNotes> 00022 */ 00023 00024 /* 00025 * real_time_execution_manager.h 00026 * 00027 * Created on: Dec 10, 2009 00028 * Author: dc 00029 */ 00030 00031 #ifndef BARRETT_SYSTEMS_REAL_TIME_EXECUTION_MANAGER_H_ 00032 #define BARRETT_SYSTEMS_REAL_TIME_EXECUTION_MANAGER_H_ 00033 00034 00035 #include <string> 00036 00037 #include <boost/function.hpp> 00038 #include <boost/thread.hpp> 00039 00040 #include <libconfig.h++> 00041 00042 #include <barrett/detail/ca_macro.h> 00043 #include <barrett/systems/abstract/execution_manager.h> 00044 00045 00046 namespace barrett { 00047 namespace systems { 00048 00049 00050 class RealTimeExecutionManager : public ExecutionManager { 00051 public: 00052 typedef boost::function<void (RealTimeExecutionManager*, const ExecutionManagerException&)> callback_type; 00053 00054 explicit RealTimeExecutionManager(double period_s, int rt_priority = 50); 00055 explicit RealTimeExecutionManager(const libconfig::Setting& setting); //TODO(dc): test! 00056 virtual ~RealTimeExecutionManager(); 00057 00058 void start(); 00059 bool isRunning() const { return running; } 00060 void stop(); 00061 00062 bool getError() const { return error; } 00063 const std::string& getErrorStr() const { return errorStr; } 00064 void clearError(); 00065 00066 void setErrorCallback(callback_type callback); 00067 void clearErrorCallback(); 00068 00069 protected: 00070 boost::thread thread; 00071 int priority; 00072 bool running; 00073 00074 bool error; 00075 std::string errorStr; 00076 callback_type errorCallback; 00077 00078 void executionLoopEntryPoint(); 00079 00080 private: 00081 void init(); 00082 00083 DISALLOW_COPY_AND_ASSIGN(RealTimeExecutionManager); 00084 }; 00085 00086 00087 } 00088 } 00089 00090 00091 #endif /* BARRETT_SYSTEMS_REAL_TIME_EXECUTION_MANAGER_H_ */