00001 #ifndef OCL_DEPLOYMENTCOMPONENT_HPP
00002 #define OCL_DEPLOYMENTCOMPONENT_HPP
00003
00004 #include <rtt/RTT.hpp>
00005 #include <rtt/TaskContext.hpp>
00006 #include <rtt/Properties.hpp>
00007 #include <rtt/Attribute.hpp>
00008 #include <rtt/Ports.hpp>
00009 #include <ocl/OCL.hpp>
00010 #include <vector>
00011 #include <map>
00012
00013 namespace OCL
00014 {
00015
00022 class OCL_API DeploymentComponent
00023 : public RTT::TaskContext
00024 {
00025 protected:
00030 RTT::PropertyBag root;
00031 RTT::Property<std::string> compPath;
00032 RTT::Property<bool> autoUnload;
00033 RTT::Attribute<bool> validConfig;
00034 RTT::Constant<int> sched_RT;
00035 RTT::Constant<int> sched_OTHER;
00036 RTT::Constant<int> lowest_Priority;
00037 RTT::Constant<int> highest_Priority;
00038
00044 struct ComponentData {
00045 ComponentData()
00046 : instance(0), act(0), loaded(false),
00047 autostart(false), autoconf(false)
00048 {}
00052 RTT::TaskContext* instance;
00056 ActivityInterface* act;
00060 bool loaded;
00061 bool autostart, autoconf;
00062 };
00063
00067 struct ConnectionData {
00068 typedef std::vector<RTT::PortInterface*> Ports;
00069 Ports ports;
00070 };
00071
00075 typedef std::map<std::string, ConnectionData> ConMap;
00076 ConMap conmap;
00077
00081 typedef std::map<std::string, ComponentData> CompList;
00082 CompList comps;
00083
00088 static std::vector<std::pair<std::string,void*> > LoadedLibs;
00089
00093 void* handle;
00097 std::string libname;
00098 public:
00099 DeploymentComponent(std::string name = "Configurator");
00100
00101 ~DeploymentComponent();
00102
00112 bool connectPeers(const std::string& one, const std::string& other);
00113
00124 bool connectPorts(const std::string& one, const std::string& other);
00125
00139 bool connectPorts(const std::string& one, const std::string& one_port,
00140 const std::string& other, const std::string& other_port);
00141
00151 bool addPeer(const std::string& from, const std::string& to);
00152
00153 using TaskContext::addPeer;
00154 using TaskContext::connectPeers;
00155
00160 bool import(const std::string& path);
00161
00170 bool loadLibrary(const std::string& name);
00171
00183 bool loadComponent(const std::string& name, const std::string& type);
00184
00193 bool unloadComponent(const std::string& name);
00194
00200 void displayComponentTypes() const;
00201
00213 bool setPeriodicActivity(const std::string& comp_name,
00214 double period, int priority,
00215 int scheduler);
00216
00227 bool setNonPeriodicActivity(const std::string& comp_name,
00228 int priority,
00229 int scheduler);
00230
00240 bool setSlaveActivity(const std::string& comp_name,
00241 double period);
00242
00255 bool setActivity(const std::string& comp_name,
00256 const std::string& act_type,
00257 double period, int priority,
00258 int scheduler);
00259
00273 bool loadComponents(const std::string& config_file);
00274
00301 bool configureComponents();
00302
00308 bool startComponents();
00309
00314 void clearConfiguration();
00315
00319 bool stopComponents();
00320
00324 bool cleanupComponents();
00325
00329 bool unloadComponents();
00330
00335 bool kickStart(const std::string& file_name);
00336
00340 bool kickOut();
00341
00342 using TaskCore::configure;
00343
00352 bool configure(const std::string& name);
00353
00363 bool configureFromFile(const std::string& name, const std::string& filename);
00364
00379 bool loadConfiguration(const std::string& config_file);
00380
00387 bool loadConfigurationString(const std::string& config_text);
00388
00389 };
00390
00391
00392 }
00393 #endif