DeploymentComponent.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Jul 3 15:34:31 CEST 2008 DeploymentComponent.hpp
3 
4  DeploymentComponent.hpp - description
5  -------------------
6  begin : Thu July 03 2008
7  copyright : (C) 2008 Peter Soetens
8  email : peter.soetens@fmtc.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, *
24  * Suite 330, Boston, MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
28 
29 #ifndef OCL_DEPLOYMENTCOMPONENT_HPP
30 #define OCL_DEPLOYMENTCOMPONENT_HPP
31 
32 #include <rtt/RTT.hpp>
33 #include <rtt/TaskContext.hpp>
35 #include <rtt/Attribute.hpp>
36 #include <rtt/InputPort.hpp>
37 #include <rtt/OutputPort.hpp>
38 #include <ocl/OCL.hpp>
39 #include <vector>
40 #include <map>
42 
43 // Suppress warnings in ocl/Component.hpp
44 #ifndef OCL_STATIC
45 #define OCL_STATIC
46 #include <ocl/Component.hpp>
47 #undef OCL_STATIC
48 #else
49 #include <ocl/Component.hpp>
50 #endif
51 
52 namespace OCL
53 {
54 
86  class OCL_API DeploymentComponent
87  : public RTT::TaskContext
88  {
89  protected:
95  std::string compPath;
106 
112  struct ComponentData {
114  : instance(0), act(0), loaded(false), loadedProperties(false),
115  autostart(false), autoconf(false),
116  autoconnect(false), autosave(false),
117  proxy(false), server(false),
118  use_naming(true),
119  configfile(""),
120  group(0)
121  {}
136  bool loaded;
142  bool autostart, autoconf, autoconnect, autosave;
143  bool proxy, server, use_naming;
144  std::string configfile;
145  std::vector<std::string> plugins;
147  int group;
148  };
149 
153  struct ConnectionData {
154  typedef std::vector<RTT::base::PortInterface*> Ports;
155  typedef std::vector<RTT::TaskContext*> Owners;
156  Ports ports;
157  Owners owners;
159  };
160 
164  typedef std::map<std::string, ConnectionData> ConMap;
165  ConMap conmap;
166 
170  typedef std::map<std::string, ComponentData> CompMap;
171  typedef std::list<std::string> CompList;
172  CompMap compmap;
173  CompList comps;
174 
181  bool configureHook();
182 
187  bool unloadComponentImpl( CompMap::iterator cit );
188 
189 
197  virtual bool componentLoaded(RTT::TaskContext* c);
198 
204  virtual void componentUnloaded(RTT::TaskContext* c);
205 
214  Service::shared_ptr stringToService(std::string const& names);
223  ServiceRequester::shared_ptr stringToServiceRequester(std::string const& names);
232  base::PortInterface* stringToPort(std::string const& names);
233 
234  public:
254  DeploymentComponent(std::string name = "Deployer", std::string siteFile = "");
255 
263 
264  RTT::TaskContext* myGetPeer(std::string name) {return compmap[ name ].instance; }
265 
276  bool connectPeers(const std::string& one, const std::string& other);
277 
294  bool createConnectionMapFromPortsTag(RTT::Property<RTT::PropertyBag>& comp,
295  RTT::TaskContext* c,
296  const bool ignoreNonexistentPorts);
297 
313  bool createDataPortConnections(const bool skipUnconnected);
314 
333  bool connectPorts(const std::string& one, const std::string& other);
334 
350  bool connectPorts(const std::string& one, const std::string& one_port,
351  const std::string& other, const std::string& other_port);
352 
363  bool connect(const std::string& one, const std::string& other, ConnPolicy policy);
364 
372  bool stream(const std::string& port, ConnPolicy policy);
373 
377  bool createStream(const std::string& component, const std::string& port, ConnPolicy policy);
378 
388  bool connectServices(const std::string& one, const std::string& other);
389 
396  bool connectOperations(const std::string& required, const std::string& provided);
397 
408  bool addPeer(const std::string& from, const std::string& target);
409 
421  bool aliasPeer(const std::string& from, const std::string& target, const std::string& alias);
422 
425 
440  bool import(const std::string& package);
441 
449  void path(const std::string& path);
450 
460  bool loadLibrary(const std::string& name);
461 
471  bool reloadLibrary(const std::string& filepath);
472 
484  bool loadComponent(const std::string& name, const std::string& type);
485 
500  bool loadService(const std::string& component, const std::string& service);
501 
510  bool unloadComponent(const std::string& name);
511 
517  void displayComponentTypes() const;
518 
524  std::vector<std::string> getComponentTypes() const;
525 
537  bool setPeriodicActivity(const std::string& comp_name,
538  double period, int priority,
539  int scheduler);
540 
552  bool setActivity(const std::string& comp_name,
553  double period, int priority,
554  int scheduler);
555 
567  bool setFileDescriptorActivity(const std::string& comp_name,
568  double timeout, int priority,
569  int scheduler);
570 
583  bool setActivityOnCPU(const std::string& comp_name,
584  double period, int priority,
585  int scheduler, unsigned int cpu_nr);
586 
595  bool setSequentialActivity(const std::string& comp_name);
596 
606  bool setSlaveActivity(const std::string& comp_name,
607  double period);
608 
617  bool setMasterSlaveActivity(const std::string& comp_name,
618  const std::string& master_name);
619 
635  bool setNamedActivity(const std::string& comp_name,
636  const std::string& act_type,
637  double period, int priority,
638  int scheduler, const std::string& master_name = "");
639 
654  bool setNamedActivity(const std::string& comp_name,
655  const std::string& act_type,
656  double period, int priority,
657  int scheduler, unsigned cpu_affinity,
658  const std::string& master_name = "");
659 
668  bool setWaitPeriodPolicy(const std::string& comp_name,
669  int policy);
670 
686  bool loadComponents(const std::string& config_file);
700  bool loadComponentsInGroup(const std::string& config_file,
701  const int group);
702 
729  bool configureComponents();
730 
738  bool configureComponentsGroup(const int group);
739 
745  bool startComponents();
751  bool startComponentsGroup(const int group);
752 
757  void clearConfiguration();
758 
762  bool stopComponents();
768  bool stopComponentsGroup(const int group);
769 
773  bool cleanupComponents();
779  bool cleanupComponentsGroup(const int group);
780 
784  bool unloadComponents();
790  bool unloadComponentsGroup(const int group);
791 
796  bool kickStart(const std::string& file_name);
797 
814  bool kickStart2(const std::string& configurationfile,
815  const bool doStart,
816  bool& loadOk,
817  bool& configureOk,
818  bool& startOk);
819 
825  bool kickOutComponent(const std::string& comp_name);
826 
831  void kickOut(const std::string& config_file);
832 
838  bool kickOutAll();
843  bool kickOutGroup(const int group);
844 
849  bool runScript(const std::string& file_name);
850 
851  using base::TaskCore::configure;
852 
861  bool configure(const std::string& name);
862 
872  bool configureFromFile(const std::string& name, const std::string& filename);
873 
888  bool loadConfiguration(const std::string& config_file);
889 
896  bool loadConfigurationString(const std::string& config_text);
897 
902  const RTT::FactoryMap& getFactories() const;
903 
909  bool configureComponent(RTT::TaskContext *instance);
910 
916  bool configureComponent(const std::string& comp_name)
917  {
918  return this->configureComponent( this->getPeer(comp_name) );
919  }
920 
926  bool startComponent(RTT::TaskContext *instance);
927 
933  bool startComponent(const std::string& comp_name)
934  {
935  return this->startComponent( this->getPeer(comp_name) );
936  }
937 
943  bool stopComponent(RTT::TaskContext *instance);
944 
950  bool stopComponent(const std::string& comp_name)
951  {
952  return this->stopComponent( this->getPeer(comp_name) );
953  }
954 
960  bool cleanupComponent(RTT::TaskContext *instance);
961 
967  bool cleanupComponent(const std::string& comp_name)
968  {
969  return this->cleanupComponent( this->getPeer(comp_name) );
970  }
971 
979  void shutdownDeployment();
980 
987  bool waitForSignals(int *sigs, std::size_t sig_count);
988 
993  bool waitForSignal(int signumber);
994 
999  bool waitForInterrupt();
1000 
1001  };
1002 
1003 
1004 }
1005 #endif
bool startComponent(const std::string &comp_name)
RTT::Constant< int > lowest_Priority
RTT::Constant< int > highest_Priority
RTT::Attribute< std::string > target
int group
Group number this component belongs to.
std::vector< RTT::TaskContext * > Owners
RTT::Attribute< bool > validConfig
boost::shared_ptr< ServiceRequester > shared_ptr
virtual bool connectPeers(TaskContext *peer)
bool stopComponent(const std::string &comp_name)
RTT::Constant< int > sched_OTHER
RTT::Property< bool > autoUnload
std::map< std::string, ComponentLoaderSignature > FactoryMap
RTT::TaskContext * myGetPeer(std::string name)
boost::shared_ptr< Service > shared_ptr
std::map< std::string, ComponentData > CompMap
std::map< std::string, ConnectionData > ConMap
rt_allocator< U > other
std::vector< RTT::base::PortInterface * > Ports
RTT::Constant< int > sched_RT
virtual bool connectPorts(TaskContext *peer)
bool configureComponent(const std::string &comp_name)
bool connectPorts(TaskContext *A, TaskContext *B)
virtual bool connectServices(TaskContext *peer)
std::list< std::string > CompList
int nextGroup
Next group number.
virtual bool addPeer(TaskContext *peer, std::string alias="")
bool cleanupComponent(const std::string &comp_name)
bool connectPeers(TaskContext *A, TaskContext *B)


ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27