ScriptHost.h
Go to the documentation of this file.
00001 /*
00002  * ScriptHost.h
00003  *
00004  *  Created on: Oct 27, 2013
00005  *      Author: blackpc
00006  */
00007 
00008 #ifndef SCRIPTHOST_H_
00009 #define SCRIPTHOST_H_
00010 
00011 #include <iostream>
00012 #include <boost/thread.hpp>
00013 #include <boost/shared_ptr.hpp>
00014 #include <boost/foreach.hpp>
00015 
00016 #include <scriptable_monitor/InternalFunction.h>
00017 #include <scriptable_monitor/PythonScript.h>
00018 #include <scriptable_monitor/PredicatesScript.h>
00019 #include <scriptable_monitor/ScriptExecuter.h>
00020 #include <scriptable_monitor/RosTopicListener.h>
00021 
00022 #define foreach BOOST_FOREACH
00023 
00024 using namespace std;
00025 
00026 typedef boost::shared_ptr<diagnostic_msgs::DiagnosticStatus> DiagnosticStatusPtr;
00027 //#define lock(mutexObject) boost::mutex::scoped_lock mutexObject##Lock(mutexObject)
00028 
00029 struct AddScriptResponse {
00030         bool success;
00031         string message;
00032 };
00033 
00034 class ScriptHost
00035 {
00036 public:
00037         ScriptHost();
00038         virtual ~ScriptHost();
00039 
00040         void start();
00041         void stop();
00042 
00043         AddScriptResponse addScript(string sourceCode);
00044         vector<DiagnosticStatusPtr> getDiagnosticStatusesAndClear();
00045         set<PythonScriptPtr> getScripts();
00046         void deleteScript(string scriptName);
00047 
00048 private:
00049 
00053         double _executionInterval;
00054         boost::shared_ptr<boost::thread> _workThread;
00055         set<PythonScriptPtr> _scripts;
00056         ScriptExecuter _executer;
00057 
00058         boost::recursive_mutex _scriptsMutex;
00059         boost::recursive_mutex _statusesMutex;
00060         vector<DiagnosticStatusPtr> _diagnosticStatuses;
00061 
00062         void run();
00063         bool prepareScript(PythonScript& script);
00064         bool isExecutionTime(PythonScriptPtr script);
00065         bool hasAllTopicValues(PythonScriptPtr script);
00066         void addDiagnosticStatus(PythonScriptPtr script);
00067 
00068         PythonScriptPtr getScript(string scriptName);
00069         bool scriptExists(string scriptName);
00070 };
00071 
00072 #endif /* SCRIPTHOST_H_ */


scriptable_monitor
Author(s):
autogenerated on Wed Aug 26 2015 16:21:30