DeploymentComponent.hpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Peter Soetens  Thu Jul 3 15:34:31 CEST 2008  DeploymentComponent.hpp
00003 
00004                         DeploymentComponent.hpp -  description
00005                            -------------------
00006     begin                : Thu July 03 2008
00007     copyright            : (C) 2008 Peter Soetens
00008     email                : peter.soetens@fmtc.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place,                                    *
00024  *   Suite 330, Boston, MA  02111-1307  USA                                *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef OCL_DEPLOYMENTCOMPONENT_HPP
00030 #define OCL_DEPLOYMENTCOMPONENT_HPP
00031 
00032 #include <rtt/RTT.hpp>
00033 #include <rtt/TaskContext.hpp>
00034 #include <rtt/extras/Properties.hpp>
00035 #include <rtt/Attribute.hpp>
00036 #include <rtt/InputPort.hpp>
00037 #include <rtt/OutputPort.hpp>
00038 #include <ocl/OCL.hpp>
00039 #include <vector>
00040 #include <map>
00041 #include <rtt/marsh/PropertyDemarshaller.hpp>
00042 
00043 // Suppress warnings in ocl/Component.hpp
00044 #ifndef OCL_STATIC
00045 #define OCL_STATIC
00046 #include <ocl/Component.hpp>
00047 #undef OCL_STATIC
00048 #else
00049 #include <ocl/Component.hpp>
00050 #endif
00051 
00052 namespace OCL
00053 {
00054 
00086     class OCL_API DeploymentComponent
00087         : public RTT::TaskContext
00088     {
00089     protected:
00094         RTT::PropertyBag root;
00095         std::string compPath;
00096         int defaultWaitPeriodPolicy;
00097         RTT::Property<bool> autoUnload;
00098         RTT::Attribute<bool> validConfig;
00099         RTT::Constant<int> sched_RT;
00100         RTT::Constant<int> sched_OTHER;
00101         RTT::Constant<int> lowest_Priority;
00102         RTT::Constant<int> highest_Priority;
00103         RTT::Attribute<std::string> target;
00105         int nextGroup;
00106 
00112         struct ComponentData {
00113             ComponentData()
00114                 : instance(0), act(0), loaded(false), loadedProperties(false),
00115                   autostart(false), autoconf(false),
00116                   autoconnect(false),  autosave(false),
00117                   proxy(false), server(false),
00118                   use_naming(true),
00119                   configfile(""),
00120                   group(0)
00121             {}
00125             RTT::TaskContext* instance;
00130             base::ActivityInterface* act;
00136             bool loaded;
00141             bool loadedProperties;
00142             bool autostart, autoconf, autoconnect, autosave;
00143             bool proxy, server, use_naming;
00144             std::string configfile;
00145             std::vector<std::string> plugins;
00147             int group;
00148         };
00149 
00153         struct ConnectionData {
00154             typedef std::vector<RTT::base::PortInterface*> Ports;
00155             typedef std::vector<RTT::TaskContext*>   Owners;
00156             Ports ports;
00157             Owners owners;
00158             RTT::ConnPolicy policy;
00159         };
00160 
00164         typedef std::map<std::string, ConnectionData> ConMap;
00165         ConMap conmap;
00166 
00170         typedef std::map<std::string, ComponentData> CompMap;
00171         typedef std::list<std::string> CompList;
00172         CompMap compmap;
00173         CompList comps;
00174 
00181         bool configureHook();
00182 
00187         bool unloadComponentImpl( CompMap::iterator cit );
00188 
00189 
00197         virtual bool componentLoaded(RTT::TaskContext* c);
00198 
00204         virtual void componentUnloaded(RTT::TaskContext* c);
00205 
00214         Service::shared_ptr stringToService(std::string const& names);
00223         ServiceRequester::shared_ptr stringToServiceRequester(std::string const& names);
00232         base::PortInterface* stringToPort(std::string const& names);
00233 
00238         bool waitForSignal(int signumber);
00239 
00244         bool waitForInterrupt();
00245 
00246     public:
00266         DeploymentComponent(std::string name = "Deployer", std::string siteFile = "");
00267 
00274         ~DeploymentComponent();
00275 
00276         RTT::TaskContext* myGetPeer(std::string name) {return compmap[ name ].instance; }
00277 
00288         bool connectPeers(const std::string& one, const std::string& other);
00289 
00290         using TaskContext::connectPorts;
00308         bool connectPorts(const std::string& one, const std::string& other);
00309 
00325         bool connectPorts(const std::string& one, const std::string& one_port,
00326                           const std::string& other, const std::string& other_port);
00327 
00338         bool connect(const std::string& one, const std::string& other, ConnPolicy policy);
00339 
00347         bool stream(const std::string& port, ConnPolicy policy);
00348 
00352         bool createStream(const std::string& component, const std::string& port, ConnPolicy policy);
00353 
00354         using TaskContext::connectServices;
00363         bool connectServices(const std::string& one, const std::string& other);
00364 
00371         bool connectOperations(const std::string& required, const std::string& provided);
00372 
00383         bool addPeer(const std::string& from, const std::string& target);
00384 
00396         bool aliasPeer(const std::string& from, const std::string& target, const std::string& alias);
00397 
00398         using RTT::TaskContext::addPeer;
00399         using RTT::TaskContext::connectPeers;
00400 
00415         bool import(const std::string& package);
00416 
00424         void path(const std::string& path);
00425 
00435         bool loadLibrary(const std::string& name);
00436 
00446         bool reloadLibrary(const std::string& filepath);
00447 
00459         bool loadComponent(const std::string& name, const std::string& type);
00460 
00475         bool loadService(const std::string& component, const std::string& service);
00476 
00485         bool unloadComponent(const std::string& name);
00486 
00492         void displayComponentTypes() const;
00493 
00499         std::vector<std::string> getComponentTypes() const;
00500 
00512         bool setPeriodicActivity(const std::string& comp_name,
00513                                  double period, int priority,
00514                                  int scheduler);
00515 
00527         bool setActivity(const std::string& comp_name,
00528                          double period, int priority,
00529                          int scheduler);
00530 
00542         bool setFileDescriptorActivity(const std::string& comp_name,
00543                          double timeout, int priority,
00544                          int scheduler);
00545                                                  
00558         bool setActivityOnCPU(const std::string& comp_name,
00559                          double period, int priority,
00560                               int scheduler, unsigned int cpu_nr);
00561 
00570         bool setSequentialActivity(const std::string& comp_name);
00571 
00581         bool setSlaveActivity(const std::string& comp_name,
00582                               double period);
00583 
00592         bool setMasterSlaveActivity(const std::string& comp_name,
00593                                     const std::string& master_name);
00594 
00610         bool setNamedActivity(const std::string& comp_name,
00611                          const std::string& act_type,
00612                          double period, int priority,
00613                          int scheduler, const std::string& master_name = "");
00614 
00629         bool setNamedActivity(const std::string& comp_name,
00630                          const std::string& act_type,
00631                          double period, int priority,
00632                          int scheduler, unsigned cpu_affinity,
00633                          const std::string& master_name = "");
00634 
00643         bool setWaitPeriodPolicy(const std::string& comp_name,
00644                          int policy);
00645 
00661         bool loadComponents(const std::string& config_file);
00675         bool loadComponentsInGroup(const std::string& config_file,
00676                                    const int group);
00677 
00704         bool configureComponents();
00705 
00713         bool configureComponentsGroup(const int group);
00714 
00720         bool startComponents();
00726         bool startComponentsGroup(const int group);
00727 
00732         void clearConfiguration();
00733 
00737         bool stopComponents();
00743         bool stopComponentsGroup(const int group);
00744 
00748         bool cleanupComponents();
00754         bool cleanupComponentsGroup(const int group);        
00755 
00759         bool unloadComponents();
00765         bool unloadComponentsGroup(const int group);
00766 
00771         bool kickStart(const std::string& file_name);
00772 
00778         bool kickOutComponent(const std::string& comp_name);
00779 
00784         void kickOut(const std::string& config_file);
00785 
00791         bool kickOutAll();
00796         bool kickOutGroup(const int group);
00797 
00802         bool runScript(const std::string& file_name);
00803 
00804         using base::TaskCore::configure;
00805 
00814         bool configure(const std::string& name);
00815 
00825         bool configureFromFile(const std::string& name, const std::string& filename);
00826 
00841         bool loadConfiguration(const std::string& config_file);
00842 
00849         bool loadConfigurationString(const std::string& config_text);
00850 
00855         const RTT::FactoryMap& getFactories() const;
00856 
00862         bool configureComponent(RTT::TaskContext *instance);
00863 
00869         bool configureComponent(const std::string& comp_name)
00870         {
00871             return this->configureComponent(  this->getPeer(comp_name) );
00872         }
00873 
00879         bool startComponent(RTT::TaskContext *instance);
00880 
00886         bool startComponent(const std::string& comp_name)
00887         {
00888             return this->startComponent(  this->getPeer(comp_name) );
00889         }
00890 
00896         bool stopComponent(RTT::TaskContext *instance);
00897 
00903         bool stopComponent(const std::string& comp_name)
00904         {
00905             return this->stopComponent(  this->getPeer(comp_name) );
00906         }
00907 
00913         bool cleanupComponent(RTT::TaskContext *instance);
00914 
00920         bool cleanupComponent(const std::string& comp_name)
00921         {
00922             return this->cleanupComponent( this->getPeer(comp_name) );
00923         }
00924 
00932         void shutdownDeployment();
00933 
00934     };
00935 
00936 
00937 }
00938 #endif


ocl
Author(s): OCL Development Team
autogenerated on Sat Jun 8 2019 18:48:54